text
stringlengths 0
1.25M
| meta
stringlengths 47
1.89k
|
|---|---|
import plotly.express as px
from dash import dcc, html, Dash
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
import pandas as pd
import numpy as np
import os
import dash
### FIGURES ###
from .plotlyfunctions import *
# Build App
def init_dashboard(server):
dash_app = Dash(
server=server,
routes_pathname_prefix='/train/',
external_stylesheets=external_stylesheets,
title = "🍫 Truffletopia 🍭",
)
### LAYOUT ###
CONTROLS = html.Div([
html.H2("Visualization Controls"),
html.P("Choose Data File", style={'margin-top': '15px'}),
dcc.Dropdown(
multi=False,
id="file",
style={'color': colors['text']},
options=[{'label': i, 'value': i} for i in f],
value=f[0],
),
html.P("Primary Groupby", style={'margin-top': '15px'}),
dcc.Dropdown(
multi=False,
id="groupby1",
style={'color': colors['text']},
),
html.P("Secondary Groupby", style={'margin-top': '15px'}),
dcc.Dropdown(
multi=False,
id="groupby2",
style={'color': colors['text']},
),
html.Div([
dbc.Button('Refresh', id='reset', n_clicks=0)
], style={'margin-top': '15px',
'margin-bottom': '15px'}),
html.Div(id='table'),
], style={'height': '100vh'})
dash_app.layout = html.Div([
NAVBAR,
html.Div([
html.Div([
CONTROLS,
],
className = "four columns",
),
html.Div([
dcc.Store(id='df'),
html.Div(id='figures'),
html.Div(id='dummydiv'),
],
className = "eight columns",
),
],
className = "twelve columns",
style = {'padding': '10px'}
),
],
style={'backgroundColor': colors['background']}
)
init_callbacks(dash_app)
return dash_app.server
### MAIN CALLBACKS ###
def init_callbacks(app):
@app.callback(
Output('table', 'children'),
Output('figures', 'children'),
Output('df', 'data'),
Input('file', 'value'))
def view_data(name):
if 'csv' in name:
df = pd.read_csv('data/forecast/{}'.format(name))
elif 'xlsx' in name:
df = pd.read_excel('data/forecast/{}'.format(name), engine='openpyxl')
# infer dates
for col in df.columns:
if df[col].dtype == np.object:
try:
df[col] = pd.to_datetime(df[col])
except:
pass
return create_table(df),\
html.Div([
html.H1(["Coming Soon!"], style={'textAlign': 'center'})
]), df.to_json()
|
{"hexsha": "bca4aea5a257f302fd3172d28d482f8470a5553d", "size": 2984, "ext": "py", "lang": "Python", "max_stars_repo_path": "apps/dashboards/forecast/train.py", "max_stars_repo_name": "wesleybeckner/truffletopia", "max_stars_repo_head_hexsha": "574caf24b41126d3d71c45b49cfd44820c42fa7e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "apps/dashboards/forecast/train.py", "max_issues_repo_name": "wesleybeckner/truffletopia", "max_issues_repo_head_hexsha": "574caf24b41126d3d71c45b49cfd44820c42fa7e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "apps/dashboards/forecast/train.py", "max_forks_repo_name": "wesleybeckner/truffletopia", "max_forks_repo_head_hexsha": "574caf24b41126d3d71c45b49cfd44820c42fa7e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6923076923, "max_line_length": 83, "alphanum_fraction": 0.4825737265, "include": true, "reason": "import numpy", "num_tokens": 665}
|
import time
import os
import tensorflow as tf
import numpy as np
from keras.optimizers import Adam
from keras.layers import Input
import Model
import Util
class DeRed():
def __init__(self,orientation):
self.orientation = orientation
self.filter = 32
self.data_path = '../Data/'
self.weights_path = '../Weights/ATV - HUH/'
self.target_site_name = 'ATV'
self.source_site_name = 'HUH'
self.shape = self.getOrientation(orientation)
self.site_factor_encoder_source = Model.getSiteFactorEncoder(self.shape,self.filter,self.source_site_name)
self.bran_factor_encoder_source = Model.getBranFactorEncoder(self.shape,self.filter,self.source_site_name)
self.site_factor_encoder_target = Model.getSiteFactorEncoder(self.shape,self.filter,self.target_site_name)
self.bran_factor_encoder_target = Model.getBranFactorEncoder(self.shape,self.filter,self.target_site_name)
self.decoder_source = Model.getDecoder(self.shape,self.filter,self.source_site_name)
self.decoder_target = Model.getDecoder(self.shape,self.filter,self.target_site_name)
def getOrientation(self,orientation='sagittal'):
if orientation=='transverse':
return (176, 208, 3)
elif orientation=='coronal':
return (176, 176, 3)
elif orientation=='sagittal':
return (208, 176, 3)
else :
raise Exception('Illegal declaration: \'{}\','.format(orientation)+
' Only [\'transverse\', \'coronal\', \'sagittal\'] allowed.')
def loadWeights(self):
Util.loadWeights(self.site_factor_encoder_source,self.weights_path,self.orientation)
Util.loadWeights(self.bran_factor_encoder_source,self.weights_path,self.orientation)
Util.loadWeights(self.site_factor_encoder_target,self.weights_path,self.orientation)
Util.loadWeights(self.bran_factor_encoder_target,self.weights_path,self.orientation)
Util.loadWeights(self.decoder_source,self.weights_path,self.orientation)
Util.loadWeights(self.decoder_target,self.weights_path,self.orientation)
def predict(self):
self.loadWeights()
target_data,source_data,target_file_list = Util.loadImage(self.data_path,self.orientation,self.target_site_name,self.source_site_name)
s1,s2,s3 = self.site_factor_encoder_target(target_data)
b1,b2,b3,b4 = self.bran_factor_encoder_source(source_data)
s1 = tf.reduce_mean(s1,axis=0,keepdims=True)+s1*0
s2 = tf.reduce_mean(s2,axis=0,keepdims=True)+s2*0
s3 = tf.reduce_mean(s3,axis=0,keepdims=True)+s3*0
predicted_data = self.decoder_target.predict([s1,s2,s3,b1,b2,b3,b4])
Util.saveImage(predicted_data,'../Results/{}_to_{}/{}/'.format(self.source_site_name,self.target_site_name,self.orientation),target_file_list)
|
{"hexsha": "24bbc8e9ca44afa29210e56525ba5740fcdbd6af", "size": 3081, "ext": "py", "lang": "Python", "max_stars_repo_path": "Code/DeRed.py", "max_stars_repo_name": "DezhengTian/DeRed-Harmonization", "max_stars_repo_head_hexsha": "5c22d874ec61643d5dee0a43ffe817db5cae18b5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Code/DeRed.py", "max_issues_repo_name": "DezhengTian/DeRed-Harmonization", "max_issues_repo_head_hexsha": "5c22d874ec61643d5dee0a43ffe817db5cae18b5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Code/DeRed.py", "max_forks_repo_name": "DezhengTian/DeRed-Harmonization", "max_forks_repo_head_hexsha": "5c22d874ec61643d5dee0a43ffe817db5cae18b5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.037037037, "max_line_length": 150, "alphanum_fraction": 0.6692632262, "include": true, "reason": "import numpy", "num_tokens": 647}
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- vim:set ts=4 sw=4 sts=4 noet: */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "load/var.h"
#include <boost/uuid/uuid_io.hpp>
#include "bc/pack.h"
#include "cellml.h"
#include "database.h"
#include "lo.pb.h"
#include "phml.h"
#include "sbml.h"
#define BOOST_TEST_MODULE test_var
#include "test.h"
struct F : public test::MemoryFixture {
void Cellml(const char *file) {
SaveGivenFile(driver_.db(), file);
BOOST_REQUIRE(cellml::Read(driver_.db()));
}
void Phml(const char *file) {
SaveGivenFile(driver_.db(), file);
BOOST_REQUIRE(phml::Read(driver_.db(), boost::filesystem::current_path()));
}
void Sbml(const char *file) {
SaveGivenFile(driver_.db(), file);
BOOST_REQUIRE(sbml::Read(driver_.db()));
}
void GenerateAndCompare(const char *output,
const char *input)
{
BOOST_REQUIRE(load::Var(driver_.db(), output));
boost::filesystem::path fp(__FILE__);
boost::filesystem::path ep = fp.parent_path();
ep /= "var";
ep /= input;
boost::filesystem::path op(std::string(output) + ".txt");
boost::filesystem::ofstream ofs(op, std::ios::binary);
BOOST_REQUIRE(ofs);
std::ifstream ifs(output, std::ios::binary);
BOOST_REQUIRE(ifs);
lo::Header header;
BOOST_REQUIRE(UnpackFromIstream(header, &ifs));
lo::Column column;
while (UnpackFromIstream(column, &ifs)) {
boost::uuids::uuid uuid;
std::memcpy(&uuid, column.uuid().c_str(), uuid.size());
ofs << column.position()
<< ' '
<< uuid
<< ' '
<< column.id()
<< ' '
<< column.name()
<< std::endl;
}
ifs.close();
ofs.close();
test::CheckSame(op, ep);
boost::filesystem::remove(op);
std::remove(output);
}
};
BOOST_FIXTURE_TEST_SUITE(test_var, F)
BOOST_AUTO_TEST_CASE(lockwood_ewy_hermann_holford_2006) {
Cellml(TEST_MODELS("lockwood_ewy_hermann_holford_2006.cellml"));
GenerateAndCompare("lockwood_ewy_hermann_holford_2006.cellml.var",
"lockwood_ewy_hermann_holford_2006.cellml.txt");
}
BOOST_AUTO_TEST_CASE(yang_tong_mccarver_hines_beard_2006) {
Cellml(TEST_MODELS("yang_tong_mccarver_hines_beard_2006.cellml"));
GenerateAndCompare("yang_tong_mccarver_hines_beard_2006.cellml.var",
"yang_tong_mccarver_hines_beard_2006.cellml.txt");
}
BOOST_AUTO_TEST_CASE(Rybak_2006_with_static_instance_and_multiple_input) {
Phml(TEST_MODELS("Rybak_2006_with_static_instance_and_multiple_input.isml"));
GenerateAndCompare("Rybak_2006_with_static_instance_and_multiple_input.isml.var",
"Rybak_2006_with_static_instance_and_multiple_input.isml.txt");
}
BOOST_AUTO_TEST_CASE(hepatocyte_external) {
Phml(TEST_MODELS("hepatocyte_external.isml"));
boost::filesystem::remove("4d96c8de-d10a-48e2-a0e0-be9d74e58e78.db");
GenerateAndCompare("hepatocyte_external.isml.var",
"hepatocyte_external.isml.txt");
}
BOOST_AUTO_TEST_CASE(hepatocyte_internal) {
Phml(TEST_MODELS("hepatocyte_internal.isml"));
boost::filesystem::remove("4d96c8de-d10a-48e2-a0e0-be9d74e58e78.db");
boost::filesystem::remove("4d96c8de-d10a-48e2-a0e0-be9d74e58e78.xml");
GenerateAndCompare("hepatocyte_internal.isml.var",
"hepatocyte_internal.isml.txt");
}
BOOST_AUTO_TEST_CASE(ringed_Beeler_Reuter_1977_model_with_static_instance) {
Phml(TEST_MODELS("ringed_Beeler_Reuter_1977_model_with_static_instance.isml"));
GenerateAndCompare("ringed_Beeler_Reuter_1977_model_with_static_instance.isml.var",
"ringed_Beeler_Reuter_1977_model_with_static_instance.isml.txt");
}
BOOST_AUTO_TEST_CASE(BIOMD0000000114) {
Sbml(TEST_MODELS("BIOMD0000000114.xml"));
GenerateAndCompare("BIOMD0000000114.xml.var",
"BIOMD0000000114.xml.txt");
}
BOOST_AUTO_TEST_CASE(BIOMD0000000152) {
Sbml(TEST_MODELS("BIOMD0000000152.xml"));
GenerateAndCompare("BIOMD0000000152.xml.var",
"BIOMD0000000152.xml.txt");
}
BOOST_AUTO_TEST_SUITE_END()
|
{"hexsha": "81d854ea74a241feb005bb3b775da0aff0199185", "size": 3884, "ext": "cc", "lang": "C++", "max_stars_repo_path": "test/load/test_var.cc", "max_stars_repo_name": "Abhisheknishant/Flint", "max_stars_repo_head_hexsha": "441beab56d21e4069b858ae6588fa0fa3084d722", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9.0, "max_stars_repo_stars_event_min_datetime": "2015-09-07T05:33:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T03:35:08.000Z", "max_issues_repo_path": "test/load/test_var.cc", "max_issues_repo_name": "Abhisheknishant/Flint", "max_issues_repo_head_hexsha": "441beab56d21e4069b858ae6588fa0fa3084d722", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 27.0, "max_issues_repo_issues_event_min_datetime": "2018-03-19T02:10:06.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-09T08:20:51.000Z", "max_forks_repo_path": "test/load/test_var.cc", "max_forks_repo_name": "Abhisheknishant/Flint", "max_forks_repo_head_hexsha": "441beab56d21e4069b858ae6588fa0fa3084d722", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6.0, "max_forks_repo_forks_event_min_datetime": "2019-03-26T00:32:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-11T23:21:42.000Z", "avg_line_length": 29.8769230769, "max_line_length": 107, "alphanum_fraction": 0.7420185376, "num_tokens": 1171}
|
REBOL [
Title: "Testing library"
File: %spec.r
Author: "Kirill Temnov"
Date: 15/11/2015
]
test-suite: context [
name: ""
total: ""
errors: 0
fails: 0
assert: func [
block
][
if error?
try [
r: do block
either do block [
append total "."
][
append total "F"
print ["^/Fail on block" mold block]
fails: fails + 1
]
][
append total "E"
errors: errors + 1
print ["Error on block" mold block]
]
]
stat: does [
print ["^/Test suite: " name]
print ["========================================^/" total "^/"]
print ["Total test passed:" length? total ". Errors" errors ". Fails" fails]
return fails
]
]
|
{"hexsha": "b7181b5c446e1dfe4cf938592d36b5c12c1bb0be", "size": 876, "ext": "r", "lang": "R", "max_stars_repo_path": "tests/spec.r", "max_stars_repo_name": "KirillTemnov/stack-vm", "max_stars_repo_head_hexsha": "b3b5ddcc6da7e454d0433c22ad7d7ba78c279597", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-11-21T08:22:07.000Z", "max_stars_repo_stars_event_max_datetime": "2015-11-29T10:39:20.000Z", "max_issues_repo_path": "tests/spec.r", "max_issues_repo_name": "KirillTemnov/stack-vm", "max_issues_repo_head_hexsha": "b3b5ddcc6da7e454d0433c22ad7d7ba78c279597", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-06T06:19:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-06T06:19:25.000Z", "max_forks_repo_path": "tests/spec.r", "max_forks_repo_name": "KirillTemnov/stack-vm", "max_forks_repo_head_hexsha": "b3b5ddcc6da7e454d0433c22ad7d7ba78c279597", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.9090909091, "max_line_length": 84, "alphanum_fraction": 0.4075342466, "num_tokens": 216}
|
#ifndef N_BODY_PHYSICAL_HPP
#define N_BODY_PHYSICAL_HPP
#include "communication.hpp"
#include "config.hpp"
#include "data.hpp"
#include "logging.hpp"
#include "space.hpp"
#include "tree.hpp"
#include <boost/archive/xml_oarchive.hpp>
#include <boost/mpi.hpp>
#include <cmath>
#include <cstddef>
namespace n_body::physical {
using namespace n_body::data;
template <typename T, std::size_t Dimension>
void step(const config::Configuration<T> &config,
const boost::mpi::communicator &comm, int root,
data::Bodies<T, Dimension> &bodies,
const data::tree::BodyTree<T, Dimension> &tree);
template <typename T, std::size_t Dimension, typename Iter>
void step(const config::Configuration<T> &config, Iter first, Iter last,
const data::tree::BodyTree<T, Dimension> &tree);
template <typename T, std::size_t Dimension, typename Iter>
void step(const config::Configuration<T> &config, Iter first, Iter last,
const data::Bodies<T, Dimension> &bodies);
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_tree_to_position(
const config::Configuration<T> &config,
const data::tree::BodyTree<T, Dimension> &tree,
const data::Vector<T, Dimension> &position);
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_subtree_to_position(
const config::Configuration<T> &config,
const data::tree::BodyTree<T, Dimension> &tree, std::size_t root,
const data::Vector<T, Dimension> &position);
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_position_to_position(
const config::Configuration<T> &config,
const data::Vector<T, Dimension> &other_position,
data::Scalar<T> other_mass, const data::Vector<T, Dimension> &position);
// update bodies one step
template <typename T, std::size_t Dimension>
void step(const config::Configuration<T> &config,
const boost::mpi::communicator &comm,
data::Bodies<T, Dimension> &bodies,
const data::tree::BodyTree<T, Dimension> &tree) {
communication::Division division(comm, bodies.size());
data::Bodies<T, Dimension> local_bodies(&bodies[division.begin],
&bodies[division.end]);
// step(config, local_bodies.begin(), local_bodies.end(), tree);
step(config, local_bodies.begin(), local_bodies.end(), bodies);
boost::mpi::all_gather(comm, local_bodies.data(), division.count, bodies);
}
// update bodies one step by iterator
template <typename T, std::size_t Dimension, typename Iter>
void step(const config::Configuration<T> &config, Iter first, Iter last,
const data::Bodies<T, Dimension> &bodies) {
for (; first != last; ++first) {
data::Vector<T, Dimension> acceleration{
0,
0,
0,
};
for (const auto &body : bodies) {
acceleration += gravity_per_unit_mass_position_to_position(
config, body.position, body.mass, first->position);
}
first->velocity += config.time * acceleration;
first->position += config.time * first->velocity;
}
}
// update bodies one step by iterator
template <typename T, std::size_t Dimension, typename Iter>
void step(const config::Configuration<T> &config, Iter first, Iter last,
const data::tree::BodyTree<T, Dimension> &tree) {
for (; first != last; ++first) {
auto acceleration =
gravity_per_unit_mass_tree_to_position(config, tree, first->position);
first->velocity += config.time * acceleration;
first->position += config.time * first->velocity;
}
}
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_tree_to_position(
const config::Configuration<T> &config,
const data::tree::BodyTree<T, Dimension> &tree,
const data::Vector<T, Dimension> &position) {
if (tree.tree.empty())
return {0, 0, 0};
return gravity_per_unit_mass_subtree_to_position(config, tree, 0, position);
}
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_subtree_to_position(
const config::Configuration<T> &config,
const data::tree::BodyTree<T, Dimension> &tree, std::size_t root,
const data::Vector<T, Dimension> &position) {
if (tree.node(root).node_type() == data::tree::NodeType::Inner) {
auto position_in_space = space::contains(tree.node(root).space, position);
auto space_size = space::size_of_space(tree.node(root).space);
auto distance = data::module_of(position - tree.node(root).center_of_mass);
if (!position_in_space && (space_size / distance) < config.theta) {
return gravity_per_unit_mass_position_to_position(
config, tree.node(root).center_of_mass, tree.node(root).mass,
position);
} else {
data::Vector<T, Dimension> sum{
0,
0,
0,
};
for (std::size_t i = 0;
i < data::tree::BodyTreeInnerNode<T, Dimension>::CHILDREN_NUMBER;
++i) {
if (auto subtree = tree.child_of_node(root, i)) {
sum += gravity_per_unit_mass_subtree_to_position(config, tree,
*subtree, position);
}
}
return sum;
}
} else {
// node is a leaf
return gravity_per_unit_mass_position_to_position(
config, tree.node(root).center_of_mass, tree.node(root).mass, position);
}
}
template <typename T, std::size_t Dimension>
data::Vector<T, Dimension> gravity_per_unit_mass_position_to_position(
const config::Configuration<T> &config,
const data::Vector<T, Dimension> &other_position,
data::Scalar<T> other_mass, const data::Vector<T, Dimension> &position) {
auto dp = other_position - position;
auto distance = data::module_of(dp);
if (distance == 0) {
return {
0,
0,
0,
};
} // singularity
auto G = config.G;
auto soften = config.soften_length;
auto result = G * other_mass /
std::pow((soften_length * soften_length + distance * distance),
static_cast<T>(3) / static_cast<T>(2)) *
dp;
return result;
}
} // namespace n_body::physical
#endif
|
{"hexsha": "1677364b618111ee7d20ad04b0faacb007c4ff55", "size": 6233, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/physical.hpp", "max_stars_repo_name": "linyinfeng/n-body", "max_stars_repo_head_hexsha": "e40c859689d76a3f36cd08e072d7ee24685e8be4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2021-11-28T15:13:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-28T15:13:06.000Z", "max_issues_repo_path": "src/physical.hpp", "max_issues_repo_name": "linyinfeng/n-body", "max_issues_repo_head_hexsha": "e40c859689d76a3f36cd08e072d7ee24685e8be4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/physical.hpp", "max_forks_repo_name": "linyinfeng/n-body", "max_forks_repo_head_hexsha": "e40c859689d76a3f36cd08e072d7ee24685e8be4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1.0, "max_forks_repo_forks_event_min_datetime": "2019-11-10T14:01:55.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-10T14:01:55.000Z", "avg_line_length": 36.6647058824, "max_line_length": 80, "alphanum_fraction": 0.6709449703, "num_tokens": 1501}
|
\documentclass[10pt]{sigplanconf}
\usepackage[compact]{titlesec}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage{color}
\usepackage{multirow}
\setlength{\textfloatsep}{8pt}
\newcommand{\Value}{\mathbf{value}}
\newcommand{\Any}{\mathbf{any}}
\newcommand{\Nil}{\mathbf{nil}}
\newcommand{\Self}{\mathbf{self}}
\newcommand{\False}{\mathbf{false}}
\newcommand{\True}{\mathbf{true}}
\newcommand{\Boolean}{\mathbf{boolean}}
\newcommand{\Integer}{\mathbf{integer}}
\newcommand{\Number}{\mathbf{number}}
\newcommand{\String}{\mathbf{string}}
\newcommand{\Void}{\Nil{*}}
\newcommand{\Const}{\mathbf{const}}
\newcommand{\mylabel}[1]{\; (\textsc{#1})}
\newcommand{\env}{\Gamma}
\newcommand{\penv}{\Pi}
\newcommand{\senv}{\Sigma}
\newcommand{\subtype}{<:}
\newcommand{\ret}{\rho}
\newcommand{\self}{\sigma}
\def\dstart{\hbox to \hsize{\vrule depth 4pt\hrulefill\vrule depth 4pt}}
\def\dend{\hbox to \hsize{\vrule height 4pt\hrulefill\vrule height 4pt}}
\begin{document}
\toappear{}
\special{papersize=8.5in,11in}
\setlength{\pdfpageheight}{\paperheight}
\setlength{\pdfpagewidth}{\paperwidth}
\conferenceinfo{DLS '15}{October 27th, 2015, Pittsburgh, PA, USA}
\copyrightyear{2015}
\copyrightdata{978-1-nnnn-nnnn-n/yy/mm}
\doi{nnnnnnn.nnnnnnn}
\titlebanner{Draft}
\preprintfooter{A Formalization of Typed Lua}
\title{A Formalization of Typed Lua}
\authorinfo{André Murbach Maidl}
{PUC-Rio, Brazil}
{amaidl@inf.puc-rio.br}
\authorinfo{Fabio Mascarenhas}
{UFRJ, Brazil}
{mascarenhas@acm.org}
\authorinfo{Roberto Ierusalimschy}
{PUC-Rio, Brazil}
{roberto@inf.puc-rio.br}
\maketitle
\begin{abstract}
Programmers often migrate from a dynamically typed
to a statically typed language when their simple scripts
evolve into complex programs. Optional type systems are
one way of having both static and dynamic typing
in the same language, while keeping its dynamically typed
semantics. This makes evolving a program from dynamic to
static typing a matter of describing the implied types that
it is using and adding annotations to make those types explicit.
Designing an optional type system for
an existing dynamically typed language is challenging, as its types should feel natural to programmers that are already familiar with
this language.
In this work, we give a formal description of Typed Lua, an
optional type system for Lua, with a focus on two of its novel type system features: incremental evolution of imperative record and object types that is both lightweight and type-safe, and {\em projection types}, a combination of flow typing, functions that return multiple values, and multiple assignment. While our type system is tailored to the features and idioms of Lua, its features can be adapted to other imperative scripting languages.
\end{abstract}
\category{D.3.1}{Programming Languages}{Formal Definitions and Theory}[Type Systems]
\terms
Languages, Design
\keywords
Optional Type Systems, Gradual Typing, Lua
\section{Introduction}
\label{sec:intro}
Dynamically typed languages forgo static type checking
in favor of using run-time {\em type tags} to classify
the values they compute, so its operations can use these
tags to perform run-time (or dynamic) checks and signal
errors in case of invalid operands~\cite{pierce2002tpl}.
The lack of static types allows programmers to write code
that might have required a complex type system to statically
type, at the cost of hiding defects that will only be caught
after deployment if the programmers do not properly
test their code.
In contrast, statically typed languages help programmers
detect defects during development, and also provide
a conceptual framework that helps programmers define modules
and interfaces that can be combined to structure the development
of large programs.
The early error detection and better tools for structuring
programs are two advantages of statically typed languages that
lead programmers to migrate their code from a dynamically
typed to a statically typed language when their scripts
evolve into complex programs~\cite{tobin-hochstadt2006ims}.
This migration from dynamic to static typing usually involves
different languages that have distinct syntax and semantics,
requiring a complex rewrite of existing programs instead of
incremental evolution.
Ideally, programming languages should offer programmers the
option to choose between static and dynamic typing.
\emph{Optional type systems}~\cite{bracha2004pluggable} and
\emph{gradual typing}~\cite{siek2006gradual} are two
approaches for blending static and dynamic typing in the same
language. Their aim is to offer programmers the option
of adding type annotations where static typing is needed,
allowing the incremental migration from dynamic to static
typing.
The difference between these two approaches is the
way they treat the runtime semantics of the language:
optional type systems have the {\em trace preservation}
property~\cite{strongscript}, where type annotations
do not influence runtime behavior, and the original
semantics of the dynamically typed language is preserved,
while gradual typing changes the semantics to
include more extensive runtime checking in the
interface between typed and untyped code.
In an optionally-typed language, dynamically typed code
can lead to type errors in statically typed code, even
if the optional type system is sound. In a gradually-typed
language, the extra runtime checks ensure that
this does not occur.
The decision
between the two approaches is not binary, and languages
can have both optional and gradual types~\cite{liketypes,strongscript}.
A key feature in optional type systems is usability.
Optional type systems retrofitted to an existing
language should fit the language's idioms, adding
static type safety to them. If the system is too
simple it may require too much of a change in the way
programmers use the language. On the other hand,
if it is too complex it may overload the programmers
with types and error messages that are hard to
understand. The most challenging aspect of designing optional type systems is to find the right amount of complexity for a type system that feels natural to the programmers.
Lua is a small imperative language with lexically-scoped first-class functions where the only data structuring
mechanism is the \emph{table}, an associative array. Lua prefers to provide mechanisms instead of fixed policies due
to its primary use as an embedded language for configuration and
extension of other applications.
This means that even features such as a module system and
object orientation are a matter of convention on how
programs use the syntactic sugar and metaprogramming
facilities of tables, instead of
built-in language constructs. Tables can efficiently represent arrays, records, maps, modules,
objects, etc.
The result is a fragmented ecosystem of libraries, and different
ideas among Lua programmers on how they should use the language
features or on how they should structure programs. One example
of this fragmentation is the proliferation of object systems.
Typed Lua~\cite{maidl2014tl,maidl2015tl} is an optional type system for
Lua that is rich enough to preserve some of the idioms
that Lua programmers are already familiar with, while
helping programmers structure large Lua programs and
catch errors at compile-time.
In this paper, we give a formal basis to an updated version of Typed Lua's original design, with a focus on two novel type system
features that Typed Lua uses to type some tricky Lua idioms.
The lack of standard policies is a challenge for the design of
an optional type system for Lua. For this reason, the design
of Typed Lua has been informed by a mostly automated survey
of Lua idioms used by a large corpus of Lua libraries.
This paper also presents the methodology of this survey and
a summary of its results.
The first idioms that we focus on this paper is the use of assignment to build records and objects one field at a time, as in
the Lua fragment in Figure~\ref{fig:newpoint}, where the {\tt new\_point} function
is a constructor for objects with {\tt x} and {\tt y}
fields and a {\tt move} method.
\begin{figure}[t]
{\footnotesize
\begin{verbatim}
function new_point(x, y)
local point = {}
point.x, point.y = x, y
function point:move(dx, dy)
self.x, self.y = self.x + dx, self.y + dy
end
return point
end
\end{verbatim}
}
\caption{Building an object piece-by-piece}
\label{fig:newpoint}
\end{figure}
The {\tt new\_point} function builds the object piece-by-piece,
from an initially empty table. Typed Lua
lets record and object types evolve incrementally
via assignment while not sacrificing width subtyping,
where we can form a supertype of a table type by ``forgetting'' fields.
The other idiom that we focus on combines overloading on the return values of a function, multiple return values, multiple assignment
to decompose multiple return values,
and tag checks to discriminate several returned values
by checking just one of them. The Lua fragment in Figure~\ref{fig:over} shows a function with overloaded multiple
returns, and how a caller of this function can discriminate
which list of multiple values the function returned.
\begin{figure}[t]
{\footnotesize
\begin{verbatim}
function idiv(x, y)
if y == 0 then return nil, "division by zero"
else return x // y, x % y end
end
local q, r = idiv(a, b)
if q then assert(a == q*b + r)
else error(r) end
\end{verbatim}
}
\caption{Overloading on multiple returns}
\label{fig:over}
\end{figure}
In the {\bf then} branch it is guaranteed that both {\tt q}
and {\tt r} are integers, and in the {\bf else} branch it is
guaranteed that {\tt q} is {\tt nil} and {\tt r} is a string.
In Typed Lua, the return type of {\tt idiv} can be a union of
tuples describing the possible return values. Typed Lua deconstructs unions of tuples into {\em projection types}, and these types track
the dependencies between the types of each value in the tuple.
The remainder of the paper is organized as follows:
Section \ref{sec:statistics} presents the methodology and results of
our survey of Lua idioms;
Section \ref{sec:types} presents the types of Typed Lua's
type system; Section~\ref{sec:subtyping} presents
their subtyping and consistent-subtyping relations;
Section \ref{sec:rules} presents the typing rules
for the two idioms that we focus on this paper;
Section \ref{sec:related} reviews related work;
Section \ref{sec:conclusion} presents our conclusions,
and outlines plans for future work.
\section{A Survey of Lua Idioms}
\label{sec:statistics}
In order to find out how Lua is used in practice, to inform
the design of Typed Lua, we did a survey of existing Lua
libraries. Our corpus is the repository for the LuaRocks
package manager~\cite{hisham2013luarocks}, downloaded on
February 1st, 2014. We did not survey all of the Lua
scripts in the repository: scripts that were not compatible
with Lua 5.2 (the version of Lua at that time) were ignored,
and we also ignored machine-generated scripts and test scripts,
as those could skew the result towards non-idiomatic uses
of Lua. This left 2,598 scripts out of a total of 3,928, from
262 different projects. The scripts were parsed, and their
abstract syntax trees analyzed to collect the data that we
show in the rest of this section.
Tables are the core data structure of Lua programs, and
the language has features that let tables be used as
tuples, lists, maps, records, abstract data types, classes,
objects, modules, etc. We performed several analyses to
quantify the different ways that Lua programs use tables.
Our first analysis surveyed table constructors (expressions
that create and initialize a table) to find out how a table
begins its life. Of all of the 23,185 table constructors of
our corpus, 36\% of them create a record (a table with string
keys such as \texttt{\{x = 1, y = 2\}}), 29\% of them create
a list or a tuple (a table with consecutive integer keys such as \texttt{\{"one", "two", "three", "four"\}}), 26\% of them create an empty table, and 8\% of them create a table with
both a record part and a list part. The remaining 1\% of them create a table with non-literal keys.
We also analyzed expressions that access a table (130,448 instances), either to read a value out of it (86\% of such expressions) or to write a
value into it (14\% of such expressions). Most of the expressions
that read a value out of a table use a literal key,
either a literal string (89\% of the reads) or a literal
number (4\% of the reads). Lua has syntactic sugar that
turns field accesses using ``dot'' notation into table
accesses through literal string keys.
In 45\% of the expressions that read a value out of a table,
its value is immediately called. These calls are split almost
evenly between function calls and method calls (25\% of reads
are function calls, 20\% of reads are method calls).
These results show that the use of tables as a namespacing
mechanism for modules, as objects, and as records,
is prevalent.
Expressions that write into a table also mostly use
literal keys (69\% of them use a literal string, 2\%
of them use a literal number), although a large 29\%
of writes use non-literal keys, in contrast to only 7\% of
reads.
In order to gauge how frequently tables are used as
collections, we looked for the presence of code that
iterates over tables, and found out that 23\% of the
scripts in our corpus iterate over a map at least once,
and 27\% of the scripts iterate over a list at least once.
Besides measuring the number of method calls, we also
measured other kinds of expressions and statements to gauge
how frequently Lua programmers use the object-oriented paradigm.
Our corpus has 24,858 function declarations, and 23\% of these
are method declarations. Of the 262 projects in our corpus,
63\% use {\em metatables}, a metaprogramming mechanism that
lets the program extend the behavior of tables and is mostly
used for implementing prototype-based inheritance.
Typed Lua's table types, described in the next section,
reflect the way Lua programmers use Lua tables in practice,
according to the results above. A table type can express
records, tuples, maps, lists, objects, or a combination of
those.
Lua modules are tables containing the modules' exports.
The current idiomatic way to define a module is to populate
an initially empty table with the members the module wishes
to export, and return this table at the end of the script
that defines the module. Around two-thirds of the modules
in our corpus use this idiom. The other third uses a
deprecated idiom, where a call to the {\tt module} function
at the top of the script installs a new global environment,
and the exported members are global variables assigned to
in the rest of the module.
The global environment is a also a table, so the two idioms
are equivalent in terms of how Typed Lua deals with module
definitions. Modules in Typed Lua make extensive use of Typed
Lua's rules for evolution of table types
(Section~\ref{sec:tables}).
In order to gauge how common is the use of dynamic type
checking as a way to define overloaded functions, we
measured how many of the functions inspect the
tags of their input parameters, and found out that 9\%
of the functions in our corpus do this, split evenly
between using the tag in an assertion, as a form of
type checking, and using the tag to decide which code
to execute, as a form of overloading. While Typed Lua
supports both union types and flow typing, general
support for overloaded functions still has to improve.
A Lua idiom that is specially problematic for static type
systems is overloading on the number and types and
multiple return values. Around 6\% of functions use
this idiom as a way to signal errors: in case of errors,
the function returns either {\tt nil} or {\tt false} plus
either an error message or error object instead of its usual
return values or throwing an exception. The caller then
tests the first returned value to check if an error occurred
or not. Standard union types and flow typing cannot deal
with this, and Typed Lua introduces {\em projection types},
a way of tracking dependencies between types in a union of
tuples after a destructuring assignment.
\section{Types}
\label{sec:types}
\begin{figure}[t]
{\scriptsize
$$
\begin{array}{rlr}
F ::= & & \textsc{first-level types:}\\
& \;\; L & \textit{literal types}\\
& | \; B & \textit{base types}\\
& | \; \Nil & \textit{nil type}\\
& | \; \Value & \textit{top type}\\
& | \; \Any & \textit{dynamic type}\\
& | \; \Self & \textit{self type}\\
& | \; F_{1} \cup F_{2} & \textit{union types}\\
& | \; S_{1} \rightarrow S_{2} & \textit{function types}\\
& | \; \{\overline{F:V}\}_{unique|open|fixed|closed} & \textit{table types}\\
& |\; x & \textit{type variables}\\
& | \; \mu x.F & \textit{recursive types}\\
%\multicolumn{3}{c}{}\\
L ::= & & \textsc{{\tiny literal types:}}\\
& \False \; | \; \True \; | \; {\it int} \; | \; {\it float} \; | \; {\it string} &\\
%\multicolumn{3}{c}{}\\
B ::= & & \textsc{{\tiny base types:}}\\
& \Boolean \, |\, \Integer \, |\, \Number\, |\, \String &\\\\
%\multicolumn{3}{c}{}\\
%\multicolumn{3}{c}{}\\
V ::= & & \textsc{{\tiny value types:}}\\
& \;\; F \; | \; \Const \; F &\\
S ::= & & \textsc{second-level types:}\\
& \;\; P & \textit{tuple types}\\
& | \; S_{1} \sqcup S_{2} & \textit{unions of tuple types}\\
%\multicolumn{3}{c}{}\\
P ::= & & \textsc{{\tiny tuple types:}}\\
%& \;\; \Void & \textit{void type}\\
& | \; F{*} & \textit{variadic types}\\
& | \; F \times P & \textit{pair types}\\\\
\end{array}
$$
}
\caption{Type Language}
\label{fig:typelang}
\end{figure}
\begin{figure}[t]
{\footnotesize
$$
\begin{array}{rlr}
T ::= & & \textsc{expression types:}\\
& \;\; F & \textit{first-level types}\\
& | \; \phi(F_{1},F_{2}) & \textit{filter types}\\
& | \; \pi_{i}^{x} & \textit{projection types}\\
E ::= & & \textsc{expression list types:}\\
& \;\; T{*} & \textit{variadic types}\\
& | \; T \times E & \textit{pair types}\\
%K ::= & & \textsc{{\small key types:}}\\
%& \;\; L \; | \; B \; | \; \Value &\\
%\multicolumn{3}{c}{}\\
R ::= & & \textsc{filter result type:}\\
& \;\; \mathbf{void} & \textit{void type}\\
& |\; F & \textit{first-level types}
\end{array}
$$
}
\caption{Special Types}
\label{fig:special}
\end{figure}
Figure~\ref{fig:typelang} presents the abstract syntax of
the core Typed Lua types. They are split into two categories:
\emph{first-level types} and \emph{second-level types}.
First-level types represent first-class Lua values and
second-level types represent tuples of values that appear
as parameters and return values of functions.
Types are ordered by a subtype relationship, so Lua values may belong to several distinct types. The details of the subtyping
relationship are given later in Section~\ref{sec:subtyping}.
Literal types represent the type of literal boolean, number
and string values. Having just one value each, their main application is in constructing table types with fields where it is guaranteed that the value of that field will not be {\tt nil}.
The base types represent values that Lua tags as booleans,
strings, or numbers during runtime. Prior to version Lua 5.3 all Lua numbers were double-precision floating point numbers.
Lua 5.3 introduced the possibility of having 64-bit integers
as numbers, with automatic promotion of integer values to
floating-point representation as needed. As automatic
promotion makes integers essentially subtypes of floating-point numbers, Typed Lua uses $\Number$ as the type of floating-point numbers, and $\Integer$ as the type of integers.
The type $\Nil$ is the type of {\tt nil}, the value that Lua uses for undefined variables, missing parameters, and missing table keys.
Many programming languages include a bottom type to represent
an empty value that programmers can use as a default expression.
We could have used the type $\Nil$ for this role, but
this would lead to reduced static type safety. Typed Lua's
type system does not have a bottom type.
The type $\Value$ is the top type, which represents any Lua value.
Its main purpose is to be able to easily express function types
that silently ignore extra arguments, as well as easily ignoring extra r-values in multiple assignment, preserving the semantics of Lua for these operations, as they do not sacrifice type safety.
The type $\Self$ is the receiver in object-oriented method
definitions and method calls, and lets Typed Lua have objects
as regular table types with methods as regular function types
with an explicit receiver parameter.
Table types represent some of the forms that Lua
tables can take. What a particular table type denotes
depends on its {\em tag}: the {\em unique}, {\em open}
and {\em fixed} tags all denote tables where it is
guaranteed that every key belongs to one of the {\em key
types} $F_i$.
%We restrict key types to literal types,
%base types, and the top type to make the system simpler
%for the user, as our survey of Lua programs showed that
%this restriction reflects the way Lua tables are commonly used.
Fields are assignable by default, but can be marked
as non-assignable with the {\bf const} qualifier in its key type.
Having a field be {\bf const} is not a guarantee that its
value cannot change, as the table may have aliases with
a non-{\bf const} type for that field. Non-assignable
fields enable {\em depth subtyping} between table types: these
fields are covariant on the types of their values, while
assignable fields are always invariant.
The difference between {\em unique}, {\em open} and
{\em fixed} tables is the guarantees that the type system
gives about the reference to a value of that type. A
reference to an {\em unique} table is guaranteed to
point to a table that has no other references to it,
so it allows greater flexibility in reinterpreting its type;
a reference to an {\em open} table is guaranteed to have
only {\em closed} references pointing to the
same table (we will explain the meaning of the {\em closed} tag shortly), which still lets the type system
reinterpret the type of a reference, but with more
restrictions; a reference to a {\em fixed} table can have any number of
{\em fixed} or {\em closed} references point to it,
so its type cannot change
anymore.
Table types with the {\em fixed} tag are suitable for typing tables that are used as maps, lists, or even a mixture of those. The guarantee that there are no keys with a type that is not
one of the key types allows type-safe iteration on these
tables.
This guarantee forbids width subtyping, which is a necessity
for object-oriented programming, so we have the {\em closed}
tag, which removes the guarantee and allows width subtyping
between other table types and {\em closed} table types. A {\em closed} table type is akin to an object-oriented {\em interface}.
Any table type has to be \emph{well-formed}.
Informally, a table type is well-formed if key types do not overlap. A formal definition of this relation depends on
the consistent-subtyping relation which we present in the
next section, so we delay the definition until Section~\ref{sec:tables}, where the typing rules for
table types are explained.
The type $\Any$ is the dynamic type, and allows
interaction between statically and dynamically typed
portions of a program. It is neither a top nor a bottom
type, although it can work as either, as a value of
any type can be coerced to $\Any$ and vice-versa.
Gradual type systems augment these coercions with
information that can be used to blame the dynamically
typed part of the program for type errors that may occur in the
statically typed part. Currently Typed Lua only
warns the programmer that coercions to and from $\Any$
may be unsafe.
Second-level types are either tuple types or unions of tuple types, and represent sequences of values that appear as arguments, return values, and the left and right sides of
assignments. Tuple types are heterogeneous lists of first-level
types that end with a {\em variadic type}.
A variadic type $F{*}$ represents an unbounded sequence of values of type $F \cup \Nil$. Lua pads sequences with {\tt nil} to
have as many values as needed, and in Typed Lua sequences
where the number of values is statically known have a $\Nil{*}$
tail to reflect this semantics.
For clarity, we use the symbol $\sqcup$ to represent the union between two different tuple types, and reserve $\cup$ for the
union of two first-level types.
Figure~\ref{fig:special} presents some types that, while
they may not be present in type annotations, play some
special role in the type system. {\em Expression types}
denote the type of expressions in the type system, which,
in addition to first-level types, can also be
{\em filter types}, which are the result of flow typing,
and {\em projection types}, which are the result of
decomposing a union of tuples. {\em Expression list types}
denote the type of lists of expressions.
Finally, {\em filter result types}
are also used in flow typing; the {\bf void} type is
a type with no values.
\section{Subtyping and Consistent-Subtyping}
\label{sec:subtyping}
Typed Lua's type system uses subtyping to order
its types and consistent-subtyping~\cite{siek2007objects,siek2013mutable}
to model compatibility between types in a way that allows
the interaction between statically and dynamically typed
parts of the program without collapsing the subtyping
relation.
The consistent-subtyping relation is defined in terms
of subtyping, so we focus the discussion in this section
on characterizing the subtyping relation.
The subtyping rules are a deduction system for the
subtyping relation $\subtype$ between two types of the
same kind.
The variable $\senv$ is a set of subtyping assumptions used
by the subtyping relation between recursive types.
Most of the subtyping rules are standard, so we will
focus on the interesting cases.
\begin{figure}[t]
{\footnotesize
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{S-Pair}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2} \;\;\;
\senv \vdash P_{1} \subtype P_{2}}
{\senv \vdash F_{1} \times P_{1} \subtype F_{2} \times P_{2}}
\end{array}
\begin{array}{c}
\mylabel{S-Variadic}\\
\dfrac{\senv \vdash F_{1} \cup \Nil \subtype F_{2} \cup \Nil}
{\senv \vdash F_{1}{*} \subtype F_{2}{*}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-VarExpand}\\
\dfrac{\senv \vdash F_{1} \cup \Nil \subtype F_{2} \;\;\;
\senv \vdash F_{1}{*} \subtype P_{2}}
{\senv \vdash F_{1}{*} \subtype F_{2} \times P_{2}}
\end{array}
\\ \\
\begin{array}{c}
\mylabel{S-VarDrop}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2} \cup \Nil \;\;\;
\senv \vdash P_{1} \subtype F_{2}{*}}
{\senv \vdash F_{1} \times P_{1} \subtype F_{2}{*}}
\end{array}
\end{array}
\]
}
\caption{Subtyping for second-level types}
\label{fig:subtuples}
\end{figure}
Figure~\ref{fig:subtuples} shows the subtyping rules for
second-level types. Expression list types have similar
subtyping rules. Tuple types are covariant, so the subtyping rule {\sc S-Pair} for pair types is straightforward.
The semantics of Lua lets the right-hand side of an assignment
produce more values than l-values in the left-hand side,
with extra values silently dropped. It also lets the
right-hand side produce fewer values than l-values in the
left-hand side, using {\tt nil} to plug the holes. The
same behavior applies for lists of arguments vs. parameters.
Typed Lua preserves this behavior in assignment by synthesizing
tuple types that have a $\Value{*}$ tail for the left side
of an assignment. Non-variadic functions have a stricter
behavior: their parameter lists have a $\Nil{*}$ tail, so
a function can be passed any number of extra arguments
as long as they are literal {\tt nil}, but the type system will
reject extra arguments of any other type. Missing arguments
are also fine if the corresponding parameters have {\tt nil}
as a subtype: this is the Lua idiom for optional parameters.
Functions that want to keep the Lua behavior of just ignoring
any extra arguments can be variadic with type $\Value{*}$ as
the tail of their parameter tuple.
The remaining subtyping rules for second-level types
reflect this semantics. Rule {\sc S-Variadic} states
that variadic types are covariant (just having $F_1{*} \subtype F_2{*}$ iff $F_1 \subtype F_2$ would be too restrictive,
as $\Nil{*}$ would not be a subtype of $\Number{*}$).
Rules {\sc S-VarExpand} and {\sc S-VarDrop} state the
conditions when variadic tuples of different length are
compatible.
We could have the axioms $\senv \vdash F{*} \subtype F \cup \Nil \times F{*}$ and $\senv \vdash F \cup \Nil \times F{*} \subtype F{*}$ instead of the two rules above, which can be derived
from these axioms by transitivity, but having the rules makes
the subtyping relation easier to implement.
\begin{figure}[t]
{\footnotesize
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{S-TableFCtoC}\\
\dfrac{\begin{array}{c}
\forall j \; \exists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \;\
\senv \vdash F_{j}' \subtype F_{i} \;
\senv \vdash V_{i} \subtype_{c} V_{j}'
\end{array}}
{\begin{array}{c}
\senv \vdash \{\overline{F:V}\}_{fixed|closed} \subtype
\{\overline{F^\prime:V^\prime}\}_{closed}
\end{array}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-TableUtoC}\\
\dfrac{\begin{array}{c}
\forall i \; \forall j \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash V_{i} \subtype_{u} V_{j}' \\
\forall j \; \nexists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash \Nil \subtype_{o} V_{j}'
\end{array}}
{\senv \vdash \{\overline{F:V}\}_{unique} \subtype
\{\overline{F^\prime:V^\prime}\}_{closed}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-TableOtoC}\\
\dfrac{\begin{array}{c}
\forall i \; \forall j \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash V_{i} \subtype_{c} V_{j}' \\
\forall j \; \nexists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash \Nil \subtype_{o} V_{j}'
\end{array}}
{\senv \vdash \{\overline{F:V}\}_{open} \subtype
\{\overline{F^\prime:V^\prime}\}_{closed}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-TableUtoUOF}\\
\dfrac{\begin{array}{c}
\forall i \; \exists j \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \land \senv \vdash V_{i} \subtype_{u} V_{j}' \\
\forall j \; \nexists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash \Nil \subtype_{o} V_{j}'
\end{array}}
{\begin{array}{c}
\senv \vdash \{\overline{F:V}\}_{unique} \subtype
\{\overline{F^\prime:V^\prime}\}_{unique|open|fixed}
\end{array}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-TableOtoOF}\\
\dfrac{\begin{array}{c}
\forall i \; \exists j \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \land \senv \vdash V_{i} \subtype_{c} V_{j}' \\
\forall j \; \nexists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \to \senv \vdash \Nil \subtype_{o} V_{j}'
\end{array}}
{\begin{array}{c}
\senv \vdash \{\overline{F:V}\}_{open} \subtype
\{\overline{F^\prime:V^\prime}\}_{open|fixed}
\end{array}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-TableFtoF}\\
\dfrac{\begin{array}{c}
\forall j \; \exists i \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \;
\senv \vdash F_{j}' \subtype F_{i} \;
\senv \vdash V_{i} \subtype_{c} V_{j}'\\
\forall i \; \exists j \;\;\;
\senv \vdash F_{i} \subtype F_{j}' \;
\senv \vdash F_{j}' \subtype F_{i} \;
\senv \vdash V_{i} \subtype_{c} V_{j}'\\
\end{array}}
{\senv \vdash \{\overline{F:V}\}_{fixed} \subtype
\{\overline{F^\prime:V^\prime}\}_{fixed}}
\end{array}
\end{array}
\]
}
\caption{Subtyping for table types}
\label{fig:tablesub}
\end{figure}
\begin{figure}[t]
{\footnotesize
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{S-FieldClsMtoM}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2} \;\;\;
\senv \vdash F_{2} \subtype F_{1}}
{\senv \vdash F_{1} \subtype_{c} F_{2}}
\end{array}
\;
\begin{array}{c}
\mylabel{S-FieldClsItoI}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash \Const \; F_{1} \subtype_{c} \Const \; F_{2}}
\end{array}
\\ \\
\begin{array}{c}
\mylabel{S-FieldClsMtoI}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash F_{1} \subtype_{c} \Const \; F_{2}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-FieldUnqMtoM}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash F_{1} \subtype_{u} F_{2}}
\end{array}
\;
\begin{array}{c}
\mylabel{S-FieldUnqItoM}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash \Const \; F_{1} \subtype_{u} F_{2}}
\end{array}
\\ \\
\begin{array}{c}
\mylabel{S-FieldUnqItoI}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash \Const \; F_{1} \subtype_{u} \Const \; F_{2}}
\end{array}
\;
\begin{array}{c}
\mylabel{S-FieldUnqMtoI}\\
\dfrac{\senv \vdash F_{1} \subtype F_{2}}
{\senv \vdash F_{1} \subtype_{u} \Const \; F_{2}}
\end{array}
\\ \\
\begin{array}{c}
\mylabel{S-FieldOpnNtoM}\\
\dfrac{\senv \vdash \Nil \subtype F}
{\senv \vdash \Nil \subtype_{o} F}
\end{array}
\;
\begin{array}{c}
\mylabel{S-FieldOpnNtoI}\\
\dfrac{\senv \vdash \Nil \subtype F}
{\senv \vdash \Nil \subtype_{o} \Const \; F}
\end{array}
\end{array}
\]
}
\caption{Subtyping for fields}
\label{fig:subfield}
\end{figure}
Figure~\ref{fig:tablesub} shows the subtyping rules for
table types. These rules use the auxiliary relations
$\subtype_{c}$, $\subtype_{u}$, and $\subtype_{o}$
shown in Figure~\ref{fig:subfield} to handle depth
subtyping where applicable.
Rule {\sc S-TableFCtoC} for subtyping
between a {\em fixed} or {\em closed}
table type and a {\em closed} table type resembles the
standard subtyping rule between mutable records, with
width subtyping plus depth subtyping from a mutable
or immutable field to an immutable field.
Rule {\sc S-TableUtoC} for subtyping between {\em unique} and {\em closed} table types is more permissive, as the typing rules of Section~\ref{sec:tables} guarantee that an {\em unique}
table type can only appear on the left side of a subtyping
judgment if the reference to the table with the {\em unique}
tag is being destroyed. This rule allows width subtyping, depth subtyping on any field, not only immutable fields, as well as the addition of new fields and the merging of existing fields, as long as the types of the values of new and merged fields include $\Nil$.
The rationale for the permissiveness of {\sc S-TableUtoC} derives from the fact that reading a non-existing key just yields $\Nil$ instead of being an error in Lua semantics, plus the fact
that the type system guarantees that a table with an
{\em unique} type has no keys with a value that does not
belong to one of its key types, and does not have any
aliases. With these guarantees, a table with type $\{1{:}\String, 2{:}\String,
``x"{:}\Integer, ``y"{:}\Value\}_{unique}$ can be safely recast as a table with type
$\{\Number{:}\String \cup \Nil, ``x"{:}\Number, ``z"{:}
\Number \cup \Nil\}_{closed}$ as long as it becomes
inaccessible with the original type, which Section~\ref{sec:tables} will show that is the case
for any type judgment where this subtyping rule is used.
Rule {\sc S-TableOtoC} for subtyping from an {\em open} table type to a {\em closed} table type also allows width subtyping, merging fields, and adding new fields, but forbids depth subtyping between mutable fields or an immutable and a mutable field, as the typing rules guarantee that the {\em open} reference
is destroyed, but the {\em open} table may already have {\em closed} aliases.
Rule {\sc S-TableUtoUOF} for subtyping from {\em unique} to {\em unique}, {\em open} or {\em fixed} table types is still permissive, but forbids standard width subtyping, as all these table types keep the guarantee that the values of all keys in tables of these types belong to one of their key types. Merging fields and adding new fields are still allowed.
Rule {\sc S-TableOtoOF} for subtyping from {\em open} to {\em open} or {\em fixed} table types mixes the depth subtyping restrictions of rule {\sc S-TableOtoC} with the width subtyping restrictions of rule {\sc S-TableUtoUOF}, but still allows merging fields and adding new fields.
Finally, rule {\sc S-TableFtoF} for subtyping between {\em fixed} table types is the most restrictive, and does not allow width
subtyping, merging fields, or adding fields, just standard
depth subtyping.
We will revisit the subtyping rules among table types in
Section~\ref{sec:tables}.
\begin{figure}[t]
{\footnotesize
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{S-Amber}\\
\dfrac{\senv[x_{1} \subtype x_{2}] \vdash F_{1} \subtype F_{2}}
{\senv \vdash \mu x_{1}.F_{1} \subtype \mu x_{2}.F_{2}}
\end{array}
\;
\begin{array}{c}
\mylabel{S-Assumption}\\
\dfrac{x_{1} \subtype x_{2} \in \senv}
{\senv \vdash x_{1} \subtype x_{2}}
\end{array}\\\\
\begin{array}{c}
\mylabel{S-UnfoldRight}\\
\dfrac{\senv \vdash F_{1} \subtype [x \mapsto \mu x.F_{2}]F_{2}}
{\senv \vdash F_{1} \subtype \mu x.F_{2}}
\end{array}
\;
\begin{array}{c}
\mylabel{S-UnfoldLeft}\\
\dfrac{\senv \vdash [x \mapsto \mu x.F_{1}]F_{1} \subtype F_{2}}
{\senv \vdash \mu x.F_{1} \subtype F_{2}}
\end{array}
\end{array}
\]
}
\caption{Subtyping for recursive types}
\label{fig:subrec}
\end{figure}
\begin{figure}[t]
{\scriptsize
$$
\begin{array}{rlr}
s ::= & & \textsc{statements:}\\
& \;\; \mathbf{skip} & \textit{skip}\\
& | \; s_{1} \; ; \; s_{2} & \textit{sequence}\\
& | \; \overline{l} = el & \textit{multiple assignment}\\
& | \; \mathbf{while} \; e \; \mathbf{do} \; s \;
| \; \mathbf{if} \; e \; \mathbf{then} \; s_{1} \; \mathbf{else} \; s_{2} & \textit{control flow}\\
& | \; \mathbf{local} \; \overline{id{:}F} = el \; \mathbf{in} \; s & \textit{variable declaration}\\
& | \; \mathbf{local} \; \overline{id} = el \; \mathbf{in} \; s & \textit{variable declaration}\\
& | \; \mathbf{rec} \; id{:}F = e \; \mathbf{in} \; s & \textit{recursive declaration} \\
& | \; \mathbf{return} \; el & \textit{return} \\
& | \; \lfloor a \rfloor_{0} & \textit{function call}\\
& | \; \mathbf{fun} \; id_{1}{:}id_{2} \; (pl){:}S \; s \;;\; \mathbf{return} \; el & \textit{method declaration}\\
e ::= & & \textsc{expressions:}\\
& \;\; \mathbf{nil} & \textit{nil}\\
& | \; k & \textit{other literals}\\
& | \; id & \textit{variable access}\\
& | \; e_{1}[e_{2}] & \textit{table access}\\
& | \; {<}F{>} \; id & \textit{type coercion}\\
& | \; f & \textit{function declaration}\\
& | \; \{ \; \overline{[e_{1}] = e_{2}} \; \} \;
| \; \{ \; \overline{[e_{1}] = e_{2}},me \; \} & \textit{table constructor}\\
& | \; e_{1} + e_{2} \;
| \; e_{1} \; {..} \; e_{2} \;
| \; e_{1} == e_{2} \;
| \; e_{1} < e_{2} & \textit{binary operations}\\
& | \; e_{1} \;\&\; e_{2} \;
| \; e_{1} \; \mathbf{and} \; e_{2} \;
| \; e_{1} \; \mathbf{or} \; e_{2} & \textit{binary operations}\\
& | \; \mathbf{not} \; e \;
| \; \# \; e & \textit{unary operations} \\
& | \; \lfloor me \rfloor_{1} & \textit{one result}\\
l ::= & & \textsc{lvalues:}\\
& \;\; id_{l} & \textit{variable assignment}\\
& | \; e_{1}[e_{2}]_{l} & \textit{table assignment}\\
& | \; id[e] \; {<}V{>} & \textit{type coercion}\\
k ::= & & \textsc{literals:}\\
& \;\; \mathbf{false} \; | \;
\mathbf{true} \; | \;
{\it int} \; | \;
{\it float} \; | \;
{\it string} & \\
el ::= & & \textsc{expression lists:}\\
& \;\; \overline{e} \; | \;
\overline{e}, me & \\
me ::= & & \textsc{multiple results:}\\
& \;\; a & \textit{application}\\
& | \; {...} & \textit{vararg expression}\\
a ::= & & \textsc{calls:}\\
& \;\; e(el) & \textit{function call}\\
& | \; e{:}n(el) & \textit{method call}\\
f ::= & & \textsc{functions:}\\
& \;\; \mathbf{fun} \; (pl){:}S \; s \;;\; \mathbf{return} \; el & \\
pl ::= & & \textsc{parameter lists:}\\
& \;\; \overline{id{:}F} \; | \;
\overline{id{:}F},{...}{:}F & \\
\end{array}
$$
}
\caption{Abstract Syntax}
\label{fig:syntax}
\end{figure}
Figure~\ref{fig:subrec} shows the subtyping rules for
recursive types. Rule {\sc S-Amber} is the \emph{Amber rule}~\cite{cardelli1986amber} for subtyping between
two recursive types. Rules {\sc S-UnfoldRight} and {\sc S-UnfoldLeft} unfold the recursive type for establishing
subtyping between a non-recursive and a recursive type,
or vice-versa.
The dynamic type $\Any$ is only a subtype of itself and of
$\Value$, and no type except $\Any$ is a subtype of $\Any$.
The type $\Any$ interacts with other types through the
{\em consistency} and {\em consistent-subtyping}
relations~\cite{siek2007objects}. We use the symbol $\sim$ for
consistency, and $\lesssim$ for consistent-subtyping.
The type $\Any$ is trivially consistent with all types, and all types
are consistent with $\Any$. A type is also consistent with
itself. Two union types $F_1 \cup F_2$ and $F_3 \cup F_4$ are
consistent if either $F_1 \sim F_3$ and $F_2 \sim F_4$ or
$F_1 \sim F_4$ and $F_2 \sim F_3$. Two function types
$S_1 \rightarrow S_2$ and $S_3 \rightarrow S_4$ are consistent
if and only if $S_3 \sim S_1$ and $S_2 \sim S_4$. Two table types are consistent if and only if they have the same key types, and the value types of each key type are consistent. Two recursive types are consistent if and only if their contents are consistent assuming that their type variables are consistent. Unions of tuple types follow the same rules as unions of first-level types. Variadic types are consistent if and only if their base types are consistent.
Finally, pair types $F_1 \times P_1$ and $F_2 \times P_2$ are
consistent if and only if $F_1 \sim F_2$ and $P_1 \sim P_2$.
In a language with subtyping, the consistency relation is
too restrictive. We need to combine it with subtyping into a
{\em consistent-subtyping} relation. The definition is
straightforward: a type is a consistent-subtype
of another if the first type is a subtype of a type
that is consistent with the other, or if the first type
is consistent with a type that is a subtype of the other.
The implementation of Typed Lua also uses consistent-subtyping to normalize and simplify union types.
For instance, the union type $\Boolean \cup \Any$ simplifies
to $\Any$, because $\Boolean$ is a consistent-subtype
of $\Any$. Another example is the union type
$\Number \cup \Nil \cup 1$, that simplifies to
$\Number \cup \Nil$, because $1$ is a consistent-subtype of $\Number$.
\section{Typing rules}
\label{sec:rules}
\begin{figure*}[t]
{\footnotesize
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{T-Constructor}\\
\dfrac{\begin{array}{c}
\overline{\env_v, \penv \vdash e_1: F_1, \env_f}
\;\;\;
\overline{\env_1, \penv \vdash e_2: F_2, \env_v} \\
T = \{\overline{F_1{:}vt(F_1,F_2)}\}_{unique} \;\;\;
\env_{2} = merge(\overline{\env_{f}}) \;\;\; wf(T)
\end{array}}
{\env_{1}, \penv \vdash \{\;\overline{[e_{1}] = e_{2}}\;\}:T, \env_{2}}
\end{array}
\begin{array}{c}
\mylabel{T-NewFieldUnique}\\
\dfrac{\begin{array}{c}
\env_{1}(id) = \{ \overline{F:V} \}_{unique}\\
\env_{1}, \penv \vdash e:F^{new}, \env_{2} \;\;\;
\overline{F^{new} \not\lesssim F} \;\;\;
V^{new} = vt(F^{new}, V)
\end{array}}
{\begin{array}{l}
\env_{1}, \penv \vdash id[e] {<}V{>}:V^{new},
\env_{2}[id \mapsto \{ \overline{F{:}V}, F^{new}{:}V^{new}\}_{unique}]
\end{array}}
\end{array}\\\\
\begin{array}{c}
\mylabel{T-IdRead}\\
\dfrac{\env(id) = F}
{\env, \penv \vdash id:close(F), \env[id \mapsto open(F)]}
\end{array}
\begin{array}{c}
\mylabel{T-IdWrite}\\
\dfrac{\env(id) = F}
{\env, \penv \vdash id_{l}:F, \env}
\end{array}
\begin{array}{c}
\mylabel{T-IndexIdRead}\\
\dfrac{\begin{array}{c}
\env_{1}(id) = \{\overline{F:V}\} \;\;\;
\env_{1}, \penv \vdash e_{2}:F^e, \env_{2} \;\;\;
F^e \lesssim F_{i}
\end{array}}
{\env_{1}, \penv \vdash id[e_{2}]:rconst(V_{i}), \env_{2}}
\end{array}
\\ \\
\begin{array}{c}
\mylabel{T-IndexExpRead}\\
\dfrac{\begin{array}{c}
\env_{1}, \penv \vdash e_{1}:\{\overline{F:V}\}, \env_{2}\\
\env_{2}, \penv \vdash e_{2}:F^e, \env_{3} \;\;\;
F^e \lesssim F_{i}
\end{array}}
{\env_{1}, \penv \vdash e_{1}[e_{2}]:rconst(V_{i}), \env_{3}}
\end{array}
\begin{array}{c}
\mylabel{T-CoerceClosed}\\
\dfrac{\env(id) \subtype F \;\;\; tag(F,closed)}
{\env, \penv \vdash {<}F{>} \; id:F, \env[id \mapsto reopen(F)]}
\end{array}
\begin{array}{c}
\mylabel{T-CoerceFixed}\\
\dfrac{\env(id) \subtype F \;\;\; tag(F,fixed)}
{\env, \penv \vdash {<}F{>} \; id:F, \env[id \mapsto F]}
\end{array}\\\\
\begin{array}{c}
\mylabel{T-Function}\\
\dfrac{\begin{array}{c}
closeall(\env_{1})[\overline{id \mapsto F}], \penv[\ret \mapsto S] \vdash s, \env_{2}\\
\env_{3} = openset(\env_{1}, frv(\mathbf{fun} \; (\overline{id{:}F}){:}S \; s)) \\
\env_{4} = closeset(\env_{3}, fav(\mathbf{fun} \; (\overline{id{:}F}){:}S \; s))
\end{array}}
{\env_{1}, \penv \vdash \mathbf{fun} \; (\overline{id{:}F}){:}S \; s:F_1 \times \ldots F_n \times \Void \rightarrow S, \env_{4}}
\end{array}
\begin{array}{c}
\mylabel{T-Local}\\
\dfrac{\begin{array}{c}
\env_{1}, \penv \vdash el:P, \env_{2} \\
P \lesssim F_1 \times \ldots \times F_n \times \Value{*} \\
\env_{2}[\overline{id \mapsto F}], \penv \vdash s, \env_{3}
\end{array}}
{\env_{1}, \penv \vdash \mathbf{local} \; \overline{id{:}F} = el \; \mathbf{in} \; s, (\env_{3} - \{\overline{id}\})[\overline{id \mapsto \env_2(id)}]}
\end{array}
\end{array}
\]
}
\caption{Typing Rules for Table Types}
\label{fig:tablerules}
\end{figure*}
Figure \ref{fig:syntax} presents the abstract syntax of
Core Typed Lua, a large subset of concrete syntax
that the Typed Lua compiler handles. We use this abstract
syntax in the presentation of the typing rules
for tables and evolution of table types (Section~\ref{sec:tables})
and for functions with overloaded multiple returns and
projection types (Section~\ref{sec:projections}).
Core Typed Lua simplifies the presentation of typing rules
without sacrificing expressiveness.
The main differences between Core Typed Lua and the concrete
syntax are:
\begin{itemize}
\item lack of labels and goto statements, as they are incompatible
with the {\em flow typing} of Typed Lua's type system;
\item local variable declarations have an explicit block,
instead of being just statements;
\item no {\bf elseif} clause in {\bf if} statements;
\item no {\bf repeat} and {\bf for} loops, just {\bf while};
\item the only arithmetic operator is $+$, the only relational
operators are $==$ and $<$, and the only bitwise operator
is $\&$, as all other operators have typing rules identical to
one of these;
\item type coercion for evolution of table types is explicit,
with two coercion terms, the l-value $id[e] \; {<}V{>}$ for adding a field to
a table through assignment, and the r-value ${<}F{>} \;id$ for reinterpreting
a table type to a compatible type that is expected by the context;
\item all function declarations are anonymous, so there is a
statement for recursive declarations;
\item function or method applications that throw away all
results or all but the first result are explicitly annotated
as such, instead this being implicit in their syntactic context;
\item identifiers that appear in l-value position are explicitly
annotated as such with an $l$ subscript.
\end{itemize}
We present the typing rules as a deduction system for two typing relations, one for typing statements and another for typing expressions. Typing judgments for statements have the form $\env_{1}, \penv \vdash s, \env_{2}$, meaning that
given a type environment $\env_{1}$ and a {\em projection environment} $\penv$ we can prove that a statement $s$ produces a new type environment $\env_{2}$. Typing judgments for
expressions have the form $\env_{1}, \penv \vdash e : T, \env_{2}$, meaning that given a type environment $\env_{1}$
and a projection environment $\penv$ we can prove that an expression $e$ has type $T$ and produces a new type environment $\env_{2}$.
Only the most relevant rules are shown. The first author's Ph. D. thesis has the full set of rules~\cite{maidl2015tl}.
The type environment is standard, and maps
identifiers to expression types. Some typing rules of
Section~\ref{sec:tables} can change the type of an identifier,
so the typing relation has both an input and an output type
environment. The {\em projection environment} $\Pi$ maps projection labels to second-level types, and we explain
its use in Section~\ref{sec:projections}.
\subsection{Tables and Evolution of Table Types}
\label{sec:tables}
\begin{figure}
{\footnotesize
\[
\begin{array}{rcl}
wf(\{\overline{F:V}\}_{u|o|f|c}) & = &
\forall i \; ((\nexists j \; i \not= j \,\wedge\, F_{i} \lesssim F_{j}) \,\wedge \\
& & wf(V_{i}) \,\wedge\, \lnot tag(V_{i},unique) \,\wedge\\
& & \lnot tag(V_{i},open))\\
wf({\bf const}\; F) & = & wf(F) \\
wf(F_1 \cup F_2) & = & wf(F_1) \,\wedge\, wf(F_2) \\
wf(\mu x.F) & = & wf(F) \\
wf(S_1 \rightarrow S_2) & = & wf(S_1) \,\wedge\, wf(S_2) \\
wf(S_1 \sqcup S_2) & = & wf(S_1) \,\wedge\, wf(S_2)\\
wf(F{*}) &=& wf(F) \\
wf(F \times P) &=& wf(F) \,\wedge\,wf(P)\\
wf(F) & = & \top \;\;\;\mathrm{for\; all\; other\; cases}\\\\
tag(F_1 \cup F_2, t) & = & tag(F_1, t) \,\vee\, tag(F_2,t) \\
tag(\{\overline{F:V}\}_t, t) & = & \top\\
\multicolumn{3}{c}{
\;\;\;\;\mathrm{other\;recusive\;cases\;are\;similar,\;other\;base\;cases\;are\;}\bot}\\
\\\\
vt(L, V) & = & fix(V) \\
vt(F_1, F_2) & = & nil(fix(F_2))\\
vt(F_1, {\bf const}\;F_2) & = & {\bf const}\;nil(fix(F_2))\\\\
nil(T) & = & T \;\;\; \mathrm{if}\;\Nil \lesssim T\\
nil(T) & = & T \cup \Nil \;\;\; \mathrm{otherwise}\\\\
fix(\{\overline{F:V}\}_{unique|open}) & = &
\{\overline{F:V}\}_{fixed}\\
\multicolumn{3}{c}{\mathrm{other\;cases\;by\;straightforward\;structural\;recursion}}
\end{array}
\]}
\caption{Auxiliary Functions for Table Types}
\label{fig:funcs}
\end{figure}
\begin{figure*}
{\footnotesize
\[
\begin{array}{rcl}
merge(\overline{\env}) & = & reduce(\overline{\env}, merge2)\\
merge2(\env_1,\env_2) & = & \{\overline{(id,merget(\env_1(id),\env_2(id))}\}\\
merget(T_1, T_2) & = & T_1 \;\;\; \mathrm{if\;} T_2 \lesssim T_1\\
merget(T_1, T_2) & = & T_2 \;\;\; \mathrm{if\;} T_1 \lesssim T_2\\
\multicolumn{3}{c}{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\mathrm{the\;next\;case\;applies\;if}\;
\overline{V^l \lesssim_u V_r \,\vee\, V^r \lesssim_u V_l}\;\mathrm{and\;the\;right\; side\; is\;}wf}\\
merget(\{\overline{F:V^l},\overline{F^{\prime}:V^\prime}\}_{unique},
\{\overline{F:V^r},\overline{F^{\prime\prime}:V^{\prime\prime}}\}_{unique}) &=&
\{\overline{F:sup_u(V^l,V^r)},\overline{F^\prime:V^\prime},\overline{F^{\prime\prime}:V^{\prime\prime}}\}_{unique}
\\
\multicolumn{3}{c}{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\mathrm{the\;next\;case\;applies\;if}\;
\overline{V^l \lesssim_c V_r \,\vee\, V^r \lesssim_c V_l}\;\mathrm{and\;the\;right\; side\; is\;}wf}\\
merget(\{\overline{F:V^l},\overline{F^{\prime}:V^{\prime}}\}_{unique|open},
\{\overline{F:V^r},\overline{F^{\prime\prime}:V^{\prime\prime}}\}_{unique|open}) &=&
\{\overline{F:sup_c(V^l,V^r)},\overline{F^\prime:V^\prime},\overline{F^{\prime\prime}:V^{\prime\prime}}\}_{open}
\\
merget(T_1, T_2) & = & \bot \;\;\; \mathrm{otherwise}\\\\
join(\env_1,\env_2) & = & \{\overline{(id,joint(\env_1(id),\env_2(id))}\}\\
joint(T_1, T_2) & = & T_1 \;\;\; \mathrm{if\;} T_2 \lesssim T_1\\
joint(T_1, T_2) & = & T_2 \;\;\; \mathrm{if\;} T_1 \lesssim T_2\\
\multicolumn{3}{c}{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\mathrm{the\;next\;case\;applies\;if}\;
\overline{V^l \lesssim_u V_r \,\vee\, V^r \lesssim_u V_l}\;\mathrm{and\;the\;right\; side\; is\;}wf}\\
joint(\{\overline{F:V^l},\overline{F^{\prime}:V^{\prime}}\}_{unique},
\{\overline{F:V^r},\overline{F^{\prime\prime}:V^{\prime\prime}}\}_{unique}) &=&
\{\overline{F:sup_u(V^l,V^r)},\overline{F^\prime:nil(V^\prime)},\overline{F^{\prime\prime}:nil(V^{\prime\prime})}\}_{unique}\\
joint(T_1, T_2) & = & \bot \;\;\; \mathrm{otherwise}\\\\
sup_u(V_1, V_2) \,=\, V_2 \;\;\; \mathrm{if}\; V_1 \lesssim_u V_2 & &
sup_u(V_1, V_2) \,=\, V_1 \;\;\; \mathrm{if}\; V_2 \lesssim_u V_1 \\
\\
reopen(\{\overline{F:V}\}_{closed}) \,=\, \{\overline{F:V}\}_{open} & &
reopen(F) \,=\, F\end{array}
\]}
\caption{Merge and Join Functions}
\label{fig:mergejoin}
\end{figure*}
The simplest expression involving tables is the empty
table constructor $\{\}$. The empty table constructor always
has type $\{\}_{unique}$. A more interesting example is $\{ [``x"] = 1, [``y"] = 2 \}$, which has type $\{ ``x":1 , ``y": 2 \}_{unique}$. The subtyping rule for {\em unique} tables lets
us assign this table to a variable with a more general
type: $\{ ``x":\Number , ``y": \Number \}_{unique}$, or
even $\{ \String:\Number \cup \Nil \}_{unique}$.
Figure~\ref{fig:tablerules} presents the typing rules for table types.
Rule {\sc T-Constructor} is the rule for constructors
like the examples above, that
do not end with an expression that potentially returns
multiple values.
Due to the system for changing the table type of variables that
we will explain in this section, any expression can potentially
change the type environment. Lua semantics does not dictate
an order of evaluation among the pairs of field initializers,
so all of them are typed in the same input type environment.
The $merge$ auxiliary function then combines output
environments, diverging in case of conflicting changes.
Fields can always be added to {\em unique} and {\em open}
tables in one environment but not the other. Two environments
can add a field with the same key, as long as they have
the same type or one is a supertype of the other, respecting
any restrictions with regards to depth subtyping that the table may have.
Rule {\sc T-Constructor} also checks if the resulting type is {\em well-formed} with the predicate $wf$. Checking for well-formedness avoids ambiguous table types. An example of ambiguous table type is the type
$\{1:\Number, \Integer:\String, \Any:\Boolean\}$,
where indexing it with a key of type $\Integer$ could
yield either a number, a string or a boolean at runtime.
Well-formed table types also do not allow \emph{unique} and
\emph{open} table types to appear in the type of the values.
At the moment, local variables are the only kind of reference that the system
can track, so this restriction is
necessary. This limitation of the type system is the reason why the {\sc T-Constructor} rule uses the auxiliary function $fix$
(in the definition of $vt$)
to change any {\em open} and {\em unique} table types used in the field initializer to {\em fixed}. As an example, the table constructor $\{[``x"] = 1, [``y"] = \{[``z"] = 2\}\}$
has type $\{``x":1, ``y":\{``z":2\}_{fixed}\}_{unique}$.
There are two ways the type of {\em unique} and {\em open} tables can change in Typed
Lua. The first way is by assignment to a non-existing
field. Let us go back to the example shown in Figure~\ref{fig:newpoint}. Assuming that the type of the
$x$ and $y$ is $\Number$, we can translate the first three lines
of function {\tt new\_point} to the abstract syntax of Figure~\ref{fig:syntax}:
{\footnotesize
\begin{center}
\begin{tabular}{ll}
\multicolumn{2}{l}{$\mathbf{local} \; point: \{\}_{unique} = \{\} \; \mathbf{in}$}\\
& \multicolumn{1}{l}{$point[``x"] \; {<}\Number{>} = x;\;
point[``y"] \; {<}\Number{>} = y$}
\end{tabular}
\end{center}
}
The expressions on the left-side of the assignment are type
coercion l-values, and their type-checking is responsible
for changing the type of $point$. The type annotations in
these expressions are not
required in actual Typed Lua code, as the compiler infers the types from the corresponding expression on the right side.
Rule {\sc T-NewFieldUnique} typechecks coercion l-values on
{\em unique} table types, guaranteeing that the new type
is still well-formed. In the example above, the left
side of the first assignment changes the type of $point$
to $\{``x":\Number\}_{unique}$. The rest of the assignment
typechecks, as the right-hand side has type $\Number$.
The second assignment changes the type of $point$ to
$\{``x":\Number, ``y": \Number\}_{unique}$.
We could add both fields with a single assignment statement,
as in the following example:
{\footnotesize
\begin{center}
\begin{tabular}{ll}
\multicolumn{2}{l}{$\mathbf{local} \; point: \{\}_{unique} = \{\} \; \mathbf{in}$}\\
& \multicolumn{1}{l}{$point[``x"] \; {<}\Number{>},point[``y"] \; {<}\Number{>} = x,y;$}
\end{tabular}
\end{center}
}
In this case, the first coercion expression would still change the type of $point$ to $\{``x":\Number\}_{unique}$, but the
second would change it to $\{``y":\Number\}_{unique}$.
Merging the two yields $\{``x":\Number, ``y": \Number\}_{unique}$
through the third case of function $merget$ defined in Figure~\ref{fig:funcs}.
Open tables have a rule {\sc T-NewFieldOpen} that is not shown
in Figure~\ref{fig:tablerules} due to brevity. The only thing that
changes from one rule to the other is the tag in the type of $id$.
There are analogous rules for adding methods to {\em unique}
and {\em open tables} as a side-effect of typechecking a method declaration.
The type system needs to track aliasing of tables,
as the flexibility of {\em unique} and {\em open} tables
depend on respectively having no aliases and having only {\em closed} aliases. The system conservatively assumes that
a table has been aliased if its identifier appears in r-value position, with a couple of exceptions which we will explain shortly.
Rule {\sc T-IdRead} is responsible for tracking
aliasing. Its auxiliary function $close$ is similar to
function $fix$ defined in Figure~\ref{fig:funcs},
except that it changes the tag of {\em unique} or
{\em open} tables to {\em closed}. Its purpose
is to construct a {\em closed} type for the alias,
if necessary. Its auxiliary function $open$ is similar
to $fix$ and $close$, except that it changes the type of
{\em unique} tables to {\em open}. Its purpose
is to track the fact that an $id$ now has an alias,
if necessary.
Consider the following example, where we make an alias
of an {\em unique} table:
{\footnotesize
\begin{center}
\begin{tabular}{lll}
\multicolumn{3}{l}{$\mathbf{local} \; a:\{\}_{unique} = \{\} \; \mathbf{in}$}\\
& \multicolumn{2}{l}{$\mathbf{local} \; b:\{\}_{closed} = a \; \mathbf{in}\;\;a[``x"] \; {<}\String{>} = ``foo";$}
\end{tabular}
\end{center}
}
This example typechecks; after the initialization of $b$
the type of $a$ is {\em open} instead of {\em unique}, but
this still lets the assignment add a new field to $a$.
If we changed the tag of the type annotation of $b$ to
any other tag the example would not typecheck anymore,
as the type of expression $a$ is $\{\}_{closed}$.
If we did not change the tag on the type produced by $a$
we could break type safety, as we could declare $b$ with
tag {\em unique} or {\em open} and add fields that would
conflict with the type of the fields in $a$, but at
runtime both reference the same table.
It is not a problem for an {\em unique} or {\em open}
table to appear as an l-value, because {\sc T-IdRead} is
sufficient to forbid the creation of an alias to another
{\em unique} or {\em open} table. For this reason,
identifiers that appear as l-values have their own rule
{\sc T-IdWrite}.
Another use of the identifier that does not create an
alias is when indexing the table. Rule {\sc T-IndexIdRead}
covers this case (function $rconst$ just strips the {\bf const} qualifier from the value type, if present). For comparison, rule {\sc T-IndexExpRead}
applies for indexing expressions where the expression
denoting the table is not an identifier. The rules for
indexing expressions in l-value position are similar,
except to make sure that the field is not {\bf const} .
A second way of changing a table type is by a
{\em coercion expression}. Coercion expressions let
an {\em unique} or {\em open} table be used in a context
that expects a table type with a different shape.
Coercion expressions always create an alias, so
the type produced by the coercion is always
{\em closed} or {\em fixed}. If the coercion is to a
{\em closed} table type the type of the table changes
to an {\em open} type with the same shape, but if
the coercion is to a {\em fixed} type the table has
to assume the same type.
Rules {\sc T-CoerceClosed} and {\sc T-CoerceFixed} type
coercion expressions ${<}F{>} \; id$.
As with coercion l-values, the Typed Lua compiler automatically
infers the type $F$, so to the programmer a coercion
expression looks just like an ordinary use of the table.
Notice that the type of $id$ after {\sc T-CoerceClosed} will be an {\em open} type
only if $F$ is a plain {\em closed} table type.
Coercion is only possible towards a supertype, although
we have seen in Section~\ref{sec:subtyping} that the lack
of aliases makes the subtyping relation of {\em unique}
very flexible.
In the example below, we use a coercion expression to
widen the type of a field in an {\em unique}
table, and then add another field, to show that the
table is now {\em open}:
{\footnotesize
\begin{center}
\begin{tabular}{llll}
\multicolumn{4}{l}{$\mathbf{local} \; a:\{\}_{unique} = \{ \} \; \mathbf{in}$}\\
& \multicolumn{3}{l}{$a[``x"] \; {<}\String{>} = ``foo";\;
a[``y"] \; {<}\String{>} = ``bar";$}\\
& \multicolumn{3}{l}{$\mathbf{local} \; b:\{``x":\String, ``y":\String \cup \Nil \}_{closed} =$}\\
& & \multicolumn{2}{l}{${<}\{``x":\String, ``y":\String \cup \Nil\}_{closed}{>} \; a \; \mathbf{in}$}\\
& & & \multicolumn{1}{l}{$a[``z"] \; {<}\Integer{>} = 1$}
\end{tabular}
\end{center}
}
The type of $a$ by the time of the inner {\bf local} block
is $\{``x":\String, ``y":\String\}_{unique}$. This type is
a subtype of $\{``x":\String, ``y":\String\cup\Nil\}_{closed}$, as {\em unique} tables
have depth subtyping even in non-{\bf const} fields.
The coercion expression and the initialization of $b$
typecheck, and the type of $a$ changes to
$\{``x":\String, ``y":\String\cup\Nil\}_{open}$.
As the type is {\em open}, we can continue adding fields
to it, but are now restricted on future coercions. For
example, we will not be able to widen the type of $``x"$
to $\String \cup \Nil$, as that could break type safety
(by writing $\Nil$ to $``x"$ using reference $a$, and reading
$``x"$ using the alias $b$).
Lua has first-class functions, so another way of aliasing
{\em unique} and {\em open} references is by closing
over them in a function body. In the environment used for
typing the function body, all {\em unique} and {\em open}
tables are {\em closed} with the auxiliary function $closeall$.
Assignment to a closed-over table can be unsafe, because the {\em reference} to it is aliased as well. In the following
example, assume that $g$ receives a parameter of type
$\{ ``x": \String \cup \Nil\}_{closed}$:
{\footnotesize
\begin{center}
\begin{tabular}{llll}
\multicolumn{4}{l}{$\mathbf{local} \; a:\{\}_{open}
= \{\} \; \mathbf{in}$}\\
& \multicolumn{3}{l}{$\mathbf{local} \; f:\Void \rightarrow \Void =\;\mathbf{fun} \; ():\Void\;\;\;
a = \{[``x"]=5\} $}\\
& & \multicolumn{2}{l}{$\mathbf{in} \; \lfloor g({<}\{``x":
\String \cup \Nil\}_{closed}{>} \; a) \rfloor_{0}$}
\end{tabular}
\end{center}
}
The type of $a$ on line 2 is $\{\}_{closed}$, so the assignment
would type-check. But then the function call on the last line
would also type-check, as $\{\}_{open}$ can be coerced to
$\{ ``x": \String \cup \Nil\}$. A solution is to change the
type of $a$ from {\em open} to {\em closed} after the function
declaration. In order to do that, we use the auxiliary function
$fav$ ({\em free assigned-to variables}) to collect this
set of identifiers, and then function $closeset$ changes
the type environment to so any of these variables that
has an {\em unique} or {\em open} table type becomes {\em closed}.
Closed-over variables that are not assigned still may
change their type if they have an {\em unique} table type
and are aliased inside the function body. We use the auxiliary
function $frv$ ({\em free referenced variables}) to collect
this set, and then function $openset$ changes any variables
with an {\em unique} table type in the environment to {\em open}.
Rule {\sc T-Function} types non-variadic function declarations,
and shows how these auxiliary functions work together.
Notice that the environment $\env_{2}$ resulting from
typing the function body is just ignored. The rule for
declaring variadic functions and recursive functions are
similar. Functions $closeall$, $closeset$, $openset$, $fav$,
and $frv$ are straightforward, and were omitted for brevity.
The following example typechecks, and uses all the parts of {\sc T-Function}:
{\footnotesize
\begin{center}
\begin{tabular}{llll}
\multicolumn{4}{l}{$\mathbf{local} \; a:\{\}_{unique}, b:\{\}_{unique} = \{\}, \{\} \; \mathbf{in}$}\\
& \multicolumn{3}{l}{$\mathbf{local} \; f:\Integer \times \Void \rightarrow \Integer \times \Void =$}\\
& & \multicolumn{2}{l}{$\mathbf{fun} \; (x:\Integer):\Integer \times \Void$}\\
& & & \multicolumn{1}{l}{$b = a \;;\; \mathbf{return} \; x + 1$}\\
& \multicolumn{3}{l}{$\mathbf{in} \; a[``x"] \; {<}\Integer{>} = 1 \;;\; \lfloor f(a[``x"]) \rfloor_0$}\\
\end{tabular}
\end{center}
}
The assignment $b=a$ typechecks because, at that point,
both $b$ and $a$ have type $\{\}_{closed}$ due to $closeall$.
The set $fav$ is $\{b\}$, and the set $frv$ is $\{a\}$.
This causes the type of $b$ to also be $\{\}_{closed}$
in the body of the inner {\bf local} statement, due to $closeset$, and the type of $a$ to be $\{\}_{open}$ due
to $openset$. Being $\{\}_{open}$, adding a new field
is allowed, changing the type of $a$ to $\{``x": \Integer\}_{open}$ after the last semicolon. After the call to
$f$, the variable $b$ is an alias to $a$ but this is not
an issue, as $\{\}_{closed}$ is a supertype of $\{``x": \Integer\}_{open}$.
\subsection{Projection Types}
\label{sec:projections}
\begin{figure*}[t]
{\footnotesize
\label{fig:projtypes}
\[
\begin{array}{c}
\begin{array}{c}
\mylabel{T-LocalProj}\\
\dfrac{\begin{array}{c}
\env_{1}, \penv \vdash el:E, \env_{2}, (x,S)\\
\env_{3} = \env_{2}[id_{1} \mapsto proj(E, 1), \ldots, id_{n} \mapsto proj(E, n)]\\
\env_{3}, \penv[x \mapsto S] \vdash s, \env_{4} \;\;\;
n = |\;\overline{id}\;|
\end{array}}
{\env_{1}, \penv \vdash \mathbf{local} \; \overline{id} = el \; \mathbf{in} \; s, (\env_{4}-\{\overline{id}\})[\overline{id \mapsto \env_2(id)}]}
\end{array}
\begin{array}{c}
\mylabel{T-ExpListProj}\\
\dfrac{\begin{array}{c}
\env_{1}, \penv \vdash e_{i}:F_{i}, \env_{i+1} \;\;\;
\env_{1}, \penv \vdash me:S, \env_{n+2} \;\;\; n=|\overline{e}|\\
S = S_1 \sqcup S_2 \;\;\;m = max(|S_1|, |S_2|) \;\;\; x \notin \Pi\\
\env_{f} = merge(\env_{1}, ..., \env_{n+2})
\end{array}}
{\env_{1}, \penv \vdash \overline{e},me:}\\ {F_{1} \times ... \times F_{n} \times \pi_{1}^{x} \times ... \times \pi_{m}^{x}{*}, \env_{f}, (x,S)}
\end{array}\\\\
\begin{array}{c}
\mylabel{T-IfFilterProjThen}\\
\dfrac{\begin{array}{c}
\env_{1}(id) = \pi_{i}^{x} \\ S_t = fonilpt(\Pi(x), i)\\
finil(proj(\Pi(x), i)) = {\bf void} \\
\env_{1}, \penv[x \mapsto S_t] \vdash s_{1}, \env_{2}
\end{array}}
{\env_{1}, \penv \vdash \mathbf{if} \; id \; \mathbf{then} \; s_{1} \; \mathbf{else} \; s_{2}, \env_{2}}
\end{array}
\begin{array}{c}
\mylabel{T-IfFilterProjElse}\\
\dfrac{\begin{array}{c}
\env_{1}(id) = \pi_{i}^{x} \\
S_e = finilpt(\Pi(x), i)\\
fonil(proj(\Pi(x), i)) = {\bf void} \\
\env_{1}, \penv[x \mapsto S_e] \vdash s_{2}, \env_{2}
\end{array}}
{\env_{1}, \penv \vdash \mathbf{if} \; id \; \mathbf{then} \; s_{1} \; \mathbf{else} \; s_{2}, \env_{2}}
\end{array}
\begin{array}{c}
\mylabel{T-IfFilterProjBoth}\\
\dfrac{\begin{array}{c}
\env_{1}(id) = \pi_{i}^{x} \\ S_t = fonilpt(\Pi(x), i) \; S_e = finilpt(\Pi(x), i)\\
\env_{1}, \penv[x \mapsto S_t] \vdash s_{1}, \env_{2} \\
\env_{1}, \penv[x \mapsto S_e] \vdash s_{2}, \env_{3} \\
\env_{4} = join(\env_{2}, \env_{3})
\end{array}}
{\env_{1}, \penv \vdash \mathbf{if} \; id \; \mathbf{then} \; s_{1} \; \mathbf{else} \; s_{2}, \env_{4}}
\end{array}
\end{array}
\]}
\caption{Rules for Projection Types}
\end{figure*}
\begin{figure}[t]
{\scriptsize
\label{fig:projtypes}
\[
\begin{array}{c}
\begin{array}{rcl}
fonilpt(P_1 \sqcup P_2, i) & = & P_2 \;\; \mathrm{if} \; fonil(proj(P_1, i)) = {\bf void} \\
fonilpt(P_1 \sqcup P_2, i) & = & P_1 \;\; \mathrm{if} \; fonil(proj(P_2, i)) = {\bf void} \\
fonilpt(P_1 \sqcup P_2, i) & = & P_1 \sqcup P_2 \;\; \mathrm{otherwise}\\
fonilpt(P \sqcup S, i) & = & fonilpt(S,i) \;\; \mathrm{if} \; fonil(proj(P, i)) = {\bf void} \\
fonilpt(P \sqcup S, i) & = & P \sqcup fonilpt(S,i) \;\; \mathrm{otherwise}\\
fonilpt(S \sqcup P_2, i) & = & fonilpt(S,i) \;\; \mathrm{if} \; fonil(proj(P, i)) = {\bf void} \\
fonilpt(S \sqcup P, i) & = & fonilpt(S,i) \sqcup P \;\; \mathrm{otherwise}\\
fonilpt(S_1 \sqcup S_2, i) & = & fonilpt(S_1,i) \sqcup fonilpt(S_2,i)
\end{array}\\\\
\begin{array}{rcl}
fonil(F_1 \cup F_2) & = & fonil(F_1) \;\; \mathrm{if}\;fonil(F_2) = {\bf void}\\
fonil(F_1 \cup F_2) & = & fonil(F_2) \;\; \mathrm{if}\;fonil(F_1) = {\bf void}\\
fonil(F_1 \cup F_2) & = & fonil(F_1) \cup fonil(F_2) \;\; \mathrm{otherwise}\\
%\multicolumn{4}{c}{\mathrm{the\;next\;two\;cases\;apply\;if\;}F
% \;\mathrm{is\;not\;a\;union}}\\
fonil(F) & = & {\bf void} \;\; \mathrm{if} \; F \subtype \Nil \; \mathrm{and} \; \Nil \subtype F\\
fonil(F) & = & F \;\; \mathrm{otherwise}
\end{array}
\end{array}
\]}
\caption{Auxiliary Functions for Projection Types}
\end{figure}
As we have seen in Section~\ref{sec:statistics}, Lua
programmers often overload the return type of functions
to denote errors, returning a {\tt nil} result and
an error message in case of an error instead of the
usual return values.
As an example, consider again the {\tt idiv} function
from Figure~\ref{fig:over}, which returns the quotient and rest of integer division, or a division by zero error. In Typed Lua, we can give a return type $(\Integer \times \Integer \times \Nil*) \sqcup (\Nil \times \String \times \Nil{*})$ to that function.
As is also shown in Figure~\ref{fig:over}, the idiom for using such
a function is to test the first returned value. We
can translate that code to the abstract syntax of
Figure~\ref{fig:syntax}, leaving placeholders for
the body of the {\bf then} and {\bf else} branches:
{\footnotesize
\begin{center}
\begin{tabular}{ll}
\multicolumn{2}{l}{$\mathbf{local} \, q, r = idiv(a, b) \, \mathbf{in} \, \mathbf{if} \, q \, \mathbf{then} \, s_1 \, \mathbf{else} \, s_2$}
\end{tabular}
\end{center}
}
A standard way of decomposing the union in the assignment
would let the type of $q$ be $\Integer \times \Nil$ and
the type of $r$ be $\Integer \times \String$. Flow typing
would narrow the type of $q$ to $\Integer$ in the {\bf then}
branch and to $\Nil$ in the {\bf else} branch, but would
leave the type of $r$ unchanged.
{\em Projection types}
are a general way to make the dependency between the types
of $q$ and $r$ survive the decomposition of the tuple,
so flow typing can narrow all of the components by testing
just one of them.
Intuitively, a projection type $\pi_{i}^{x}$ denotes the union of
the i-th components of all the tuples in the union of tuple types
denoted by the label $x$. Unions of tuple types referenced by projections are kept in their own {\em projection environment} $\Pi$. A fresh label is generated whenever the last term
in an expression list has an union of tuple types as its type.
Figure~\ref{fig:projtypes} presents the rules for introducing and filtering projection types.
Notice that in the above example the local variables $q$ and $r$ are declared without an explicit type.
The rule for typing this {\bf local} statement,
{\sc T-LocalProj}, introduces a new label in the projection
environment used for typing the {\bf if} statement.
The first judgment above the bar of rule {\sc T-LocalProj} uses the auxiliary typing relation $\env_{1}, \penv \vdash el : E, \env_{2}, (x,S)$. Rule {\sc T-ExpListProj} is the typing rule for this auxiliary
relation. It does the work of generating a fresh projection label,
and projection types associated with it, if the last term of
the expression list has a union of tuple types as its type.
The rule generates as many projection types as the the length
of the longest tuple.
In the $idiv$ example above, the combination of these two rules binds $x$ to
$(\Integer \times \Integer \times \Nil{*}) \sqcup (\Nil \times \String \times \Nil{*})$ in the projection environment $\Pi$,
and $q$ and $r$ respectively to $\pi_{1}^{x}$ and $\pi_{2}^{x}$
in the type environment used for typing the {\bf if} statement.
At this point, using $q$ or $r$ as an r-value will project
their types into either $\Integer \cup \Nil$ or $\Integer \cup \String$ via rule {\sc T-IdReadProj}, which just uses auxiliary function $proj$. The more interesting cases are inside the
branches of the {\bf if} statement, where rule {\sc T-IfFilterNilProj} filters the whole union of tuples referenced
by the projection type.
Rule \textsc{T-IfFilterProjBoth} uses the auxiliary functions \emph{fonilpt} ({\em filter-out nil in projection type}) and \emph{finilpt} ({\em filter-in nil in projection type}) to
filter the union referenced by $\pi_{i}^{x}$, respectively
filtering $\Nil$ out at every i-th component (removing
the entire tuple if it is $\Nil$) and filtering $\Nil$ in at every i-th component (removing the entire tuple if it is not $\Nil$). These functions respectively use the functions $fonil$ and $finil$ to filter regular unions, plus $proj$ to test projected components. The definitions of $finilpt$ and $finil$ are analogous to the definitions of $fonilpt$ and $fonil$.
Rule {\sc T-IfFilterProjBoth} also uses the auxiliary function $join$ defined in Figure~\ref{fig:funcs} to try to combine the environments that result from typing the two branches. In a $join$ only one environment is guaranteed to be from code that has been executed.
In our example, variable $x$ would be bound to $\Integer \times \Integer \times \Nil{*}$ inside the {\bf then} branch, and bound
to $\Nil \times \String \times \Nil{*}$ inside the {\bf else}
branch. Now $q$ and $r$ project to $\Integer$ and $\Integer$
in the {\bf then} branch, and to $\Nil$ and $\String$ in the
{\bf else} branch.
Rules {\sc T-IfFilterProjThen} and {\sc T-IfFilterProjElse}
respectively cover the case where the {\bf else} branch is unreachable and the case where the {\bf then} branch is unreachable, because either the projected type of $\pi_i^x$
is not a supertype of $\Nil$ or is $\Nil$.
Assignment to an l-value with a projection type is forbidden
(there is no rule {\sc T-IdWriteProj}). Allowing assignment is unsound, as it can break the dependency among the components of the union. In the example below,
the projected type of $r$ outside of the {\bf if} statement
is $\Integer \cup \String$, so the assignment seems correct,
but inside $s_1$ the projected type of $r$ would still be
$\Integer$:
{\footnotesize
\begin{center}
\begin{tabular}{ll}
\multicolumn{2}{l}{$\mathbf{local} \, q, r = idiv(a, b) \, \mathbf{in}\; r = ``foo" ;\; \mathbf{if} \, q \, \mathbf{then} \, s_1 \, \mathbf{else} \, s_2$}
\end{tabular}
\end{center}
}
\section{Related Work}
\label{sec:related}
Tidal Lock~\cite{tidallock} is a prototype of another optional type system for Lua. It covers just a small subset of Lua
in its current form. Its most remarkable feature is
how it structures its table types to support a form of type
evolution through imperative assignment. Typed Lua uses
the same general idea of letting the type of a table evolve
through assignment, but the structure of both the table types
and the typing rules that support this are completely different.
Sol~\cite{sol} is another experimental optional type system
for Lua. While it has some similarities to Typed Lua, it
has more limited table types: Sol tables can only be lists,
maps, and objects that follow a specific object-oriented
idiom that Sol introduces. There is no evolution of table
types.
Lua Analyzer~\cite{luaanalyzer} is another optional type
system for Lua that is specially designed to work with
Löve Studio, an IDE for game development using Lua.
It is unsound by design, and primarily for supporting
IDE autocompletion. There is no evolution of table types.
Typed Racket~\cite{tobin-hochstadt2008ts} is a statically typed version of the Racket language, which is a Scheme dialect.
The main purpose of Typed Racket is to allow programmers to combine untyped modules, which are written in Racket, with typed modules, which are written in Typed Racket. Typed Racket tracks
values that cross the boundary between the typed and
untyped parts to be able to correctly assign blame to type
errors that occur in the typed parts, so is a gradual type
system.
Typed Racket introduced {\em occurrence typing}, a form of
flow typing~\cite{tobin-hochstadt2010ltu}, where type
predicates are used to refining union types.
As this use of type predicates is common in other
dynamically-typed languages, related systems
have appeared~\cite{guha2011tlc,winther2011gtp,pearce2013ccf}.
Gradualtalk~\cite{allende2013gts} is a Smalltalk dialect
with a gradual type system. Its type system combines
nominal and structural typing.
It includes function types, union types, structural object types,
nominal object types types, a self type, and parametric polymorphism. Like Typed Lua, Gradualtalk formalizes the
interaction between typed and untyped code with consistent-subtyping. Due to the performance impact of
the runtime checks that ensure the gradual typing guarantees,
Gradualtalk can be downgraded into an optional type system
through a configuration switch~\cite{allende2013cis}.
Reticulated Python~\cite{vitousek2014deg} is a
gradual type system for Python. It is structural, based on subtyping, and includes list types,
dictionary types, tuple types, function types, set types,
object types, class types, and recursive types.
Besides static type checking, Reticulated Python also introduces
three different approaches for inserting runtime assertions
that preserve the gradual typing guarantee.
Several dynamically typed languages now have optional
type systems: Clojure~\cite{bonnaire-sergeant2015typed-clojure},
JavaScript, Python~\cite{mypy},
and PHP. While Lua has some similarities to
all of these languages, none of these optional type
systems have the features described in this paper.
Most of these languages do not have idioms
that inspired these features; JavaScript has the
idiom of adding fields to an initially empty
record through assignment, but TypeScript sidesteps
the issue by having allowing an empty record to
have any record or object type, as the type of
missing fields is the bottom type of its type system.
Grace~\cite{black2013sg} and Dart are
two languages that have been designed from scratch
to have an optional type system, instead of being
existing dynamically typed languages with a retrofitted
type system.
\section{Conclusions}
\label{sec:conclusion}
We have presented a formalization of Typed Lua,
an optional type system for Lua, with a focus on rules
for two novel features of the system that type unusual
idioms present in Lua programs.
In the first idiom, records and objects are
defined through assignment to an initially empty
table. In Typed Lua's type system the type of a
table can change, either by assignment
or by using the table in a context that expects
a different (but compatible) type from its current one.
The system tracks aliasing of tables
in order to do this type evolution in a type-safe
way.
In the second idiom, a function that can return different
kinds of tuples of return values (for example, one
tuple for its usual path, another for error conditions)
is modeled by having an union of tuple types as its return
type. A destructuring assignment on a union of tuple types
decomposes the tuple in a way that the dependencies between
the types of each member of the union can be tracked.
Narrowing the type of one of the tuple's components with
a type predicate can narrow the types of the other
components.
Usability has been a concern in the design of Typed Lua since the beginning. We realized that a design based solely on what
is possible by the semantics of Lua could lead to a
complex type system. For this reason, we surveyed a large
corpus of Lua code to identify important idioms that
our type system should support.
We performed several
case studies to evaluate how successful we were in our goal of
providing an usable type system.
We evaluated 29 modules from 8 different case studies,
and we could give precise static types to 83\% of the 449
values that these modules export.
For half of the modules, we could give precise static types to
at least 89\% of the exports from each module. The methodology,
detailed results and analysis of this evaluation is part
of the first author's Ph. D. thesis~\cite{maidl2015tl}.
Our evaluation results show that our type system can statically
type check several Lua idioms and features, though the evaluation
also exposed several limitations.
We found that the three main limitations are the lack of
full support for overloaded functions, parametric polymorphism,
and operator overloading.
Overcoming these limitations is one major target for future work,
as it will allow us to statically type check more programs.
Unlike some optional type systems, such as the type systems
of the TypeScript and Dart languages, we designed Typed Lua without deliberately unsound parts.
However, we still do not have proofs that the novel features of
our type system are sound. We are working on a generalization
of the typing rules for evolution of table types where tagged
types can be attached to arbitrary references instead of
just local variables, and expect that a proof of soundness
will come out of this effort.
Typed Lua has a working implementation\footnote{Available at
\url{https://github.com/andremm/typedlua}.}
that Lua programmers can already use as a framework to
document, test, and structure their applications.
Even applications where a full conversion to static
type checking is unfeasible in the current state
of the type system, or too much work,
Lua programmers can still use Typed Lua to document the
external interfaces of their libraries, giving the benefits of static typing
checking to the users of those libraries.
We already have feedback from Lua projects
that are evaluating the use of Typed Lua, such
as the LuaRocks package manager, which is a key
piece of infrastructure for the Lua library ecosystem,
and ZeroBrane Studio, an IDE for Lua programs that is itself
written in Lua.
\acks
The authors thank the anonymous reviewers for their feedback.
Work on Typed Lua has been supported by grants from Google
Summer of Code as well as CAPES and CNPq, two Brazilian Research Councils.
\bibliographystyle{abbrvnat}
\bibliography{paper}
\end{document}
|
{"hexsha": "da65a1761927c2f74d3233bb34ca2f0633969750", "size": 82737, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/papers/dls15/paper.tex", "max_stars_repo_name": "andremm/typedlua", "max_stars_repo_head_hexsha": "2ff68c56668da62b0fa8e7256f70f3ca1475586a", "max_stars_repo_licenses": ["MIT", "Unlicense"], "max_stars_count": 486, "max_stars_repo_stars_event_min_datetime": "2015-01-17T00:51:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T02:31:14.000Z", "max_issues_repo_path": "doc/papers/dls15/paper.tex", "max_issues_repo_name": "drinkwithwater/typedlua", "max_issues_repo_head_hexsha": "b0cb071644c1a23b7963564a9cb77b3d5ee4daa7", "max_issues_repo_licenses": ["MIT", "Unlicense"], "max_issues_count": 93, "max_issues_repo_issues_event_min_datetime": "2015-01-02T02:30:08.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-07T12:49:53.000Z", "max_forks_repo_path": "doc/papers/dls15/paper.tex", "max_forks_repo_name": "drinkwithwater/typedlua", "max_forks_repo_head_hexsha": "b0cb071644c1a23b7963564a9cb77b3d5ee4daa7", "max_forks_repo_licenses": ["MIT", "Unlicense"], "max_forks_count": 60, "max_forks_repo_forks_event_min_datetime": "2015-01-20T06:08:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T07:36:49.000Z", "avg_line_length": 44.9657608696, "max_line_length": 464, "alphanum_fraction": 0.7107098396, "num_tokens": 24955}
|
\section{Partition function}
Theories with an action can be quantized using a path integral.
The partition function in Euclidean signature is defined as
% \footnote{
% Wick rotation analytically continues time to imaginary (Euclidean) time, $t\rightarrow -i t_E$,
% then the oscillatory exponential becomes decaying. }
% the same as the canonical partition function in statistical mechanics. }
\begin{equation}
Z = \int D\phi \, e^{-S[\phi]},
\end{equation}
which is an infinite-dimensional integral,
over all possible field configurations (represented by the measure $D\phi$) on all of spacetime.
For $\mathcal{N}=2^*$ on $S^4$ and its limiting cases $\mathcal{N}=4$ (massless hypermultiplet) and pure $\mathcal{N}=2$ (infinitely-heavy hypermultiplet that is integrated out),
there is one localization locus.
It is the moduli space of Coulomb vacua,
parametrized by the vacuum expectation value of a scalar of the vector multiplet:
\begin{equation}\label{vevScalar}
\braket{\Phi_0} = \text{diag}(a_1, \ldots, a_N),
\end{equation}
where $a_i$ are real numbers.
The Coulomb phase of the theory
is a consequence of the spontaneous symmetry breaking of the bosonic quartic potential $\sim [\Phi_I, \Phi_J]^2$,
that breaks the original gauge group $U(N)$ to $U(1)^{N}$.
The result for the localized partition function is of the form:
\begin{equation}\label{Zmatrixmodel}
Z=\int \; d^N a \, \prod_{i<j} (a_i-a_j)^2 \; Z_\text{1-loop}(a)\; \left|Z_\text{inst}(a)\right|^2\; e^{- \frac{8\pi^2 N}{\lambda} \sum_k a_k^2}.
\end{equation}
The classical action comes from the curvature coupling of the scalars in \eqref{SS4}.
The 1-loop correction, for the different theories are
\begin{eqnarray}
\text{$\mathcal{N}=2^*$ SYM:} & & Z_\text{1-loop} = \prod_{i<j} \dfrac{H^2(a_i-a_j)}{H(a_i-a_j-MR) H(a_i-a_j+MR)}\\
\text{$\mathcal{N}=2$ SYM:} & & Z_\text{1-loop} = \prod_{i<j} H^2(a_i-a_j) \\
\text{$\mathcal{N}=4$ SYM:} & & Z_\text{1-loop} = 1
\end{eqnarray}
where
\begin{equation}
H(x) \equiv \prod_{n=1}^{\infty}\left(1+\dfrac{x^2}{n^2}\right)^n e^{-\frac{x^2}{n}}.
\end{equation}
% This function is $1$ at the origin and vanishes very fast away from it.
We used the 't Hooft coupling $\lambda = g_{YM}^2 N$,
and $R$ is again the radius of the hypersphere.
The instanton partition function is the generating function of instantons of topological charge $k$:
\begin{equation}
Z_\text{inst} = \sum_{k=0}^\infty (e^{i 2\pi\tau})^k Z_k,
\end{equation}
where $Z_0 = 1$ and
\begin{equation}
\tau = i \frac{4\pi}{g_\text{YM}^2} + \frac{\theta}{2\pi}
\end{equation}
is the complexified Yang-Mills coupling\footnote{
The instanton action is the pure Yang-Mills action with an additional topological term.
For an instanton of charge $k$, the action is given by:
\[
S_\text{YM} (k)=
-\frac{1}{2 g_\text{YM}^2} \text{tr} \int d^4 x \sqrt{g} F_{\mu\nu} F^{\mu\nu}
-i \frac{\theta}{8\pi^2} \text{tr} \int F \wedge F
= \left( \frac{8\pi^2}{g_\text{YM}^2} - i \theta \right) k
= - i 2 \pi \tau \, k.
\]
% This action breaks CP symmetry.
% In QCD, there is no experimental evidence of CP violation, hence $\theta$ must be very small,
% and it is a considered a fine-tuning problem called the strong CP problem.
}.
% Instantons are tunnelling events in Minkowski signature
% In QCD, the groundstate, called the $\theta$-vacuum, is considered the superposition of all vacua. }.
For the $\mathcal{N}=4$ case, $Z_\text{inst} = 1$, \cite{Okuda:2010ke}.
For the $\mathcal{N}=2$ cases, it is non-trivial, \cite{Nekrasov:2002qd}.
However, the regime of interest is the large $N$ limit:
\begin{equation}\label{largeNlimit}
N\rightarrow \infty \quad \text{and} \quad \lambda = g_\text{YM}^2 N \quad \text{is kept finite},
\end{equation}
then the expansion parameter becomes
$$e^{i 2\pi\tau}=e^{-\frac{8\pi^2 N}{\lambda} + i \theta},$$
hence the instanton contributions are expected to be exponentially suppressed.
This is checked in \cite{Russo:2013kea}.
%
% for a single instanton in $\mathcal{N}=2^*$
% \begin{equation}
% Z_\text{1-inst} = - e^{-\frac{8\pi^2 N}{\lambda} + i \theta} (M R)^2
% \sum_{l=1}^N \prod_{j\neq l}^N \dfrac{ (a_l-a_j +i)^2 - (MR)^2}{(a_l-a_j) (a_l-a_j+2i)}
% \end{equation}
% Integral representation
% \begin{equation}
% Z_\text{1-inst} = e^{-\frac{8\pi^2 N}{\lambda} + i \theta} \dfrac{2 (M R)^2}{(M R)^2+1}
% \int \frac{dz}{2\pi} \prod_{j=1}^N \dfrac{(z-a_j)^2 - (MR)^2}{(z-a_j)^2+1}
% \end{equation}
\section{Large-$N$ matrix model}
The localized partition function \eqref{Zmatrixmodel} is a matrix model.
% Therefore, it is convenient to think of it as an analogous statistical model, as we shall see.
For the $\mathcal{N}=4$ case, the model is particularly simple,
it is the well-known Gaussian unitary ensemble (GUE) in the random matrix theory.
The product of the eigenvalue differences is the Vandermonde determinant squared,
which is essentially the Jacobian factor after diagonalizing the Hermitean matrix in \eqref{vevScalar}.
Writing it in terms of the effective action:
\begin{equation}\label{eq:ZGUE}
Z_\text{GUE} = \int \; d^N a \; e^{- S[a]},
\quad S[a]=- \sum_{i\neq j}^N \log(|a_i-a_j|) + \frac{8\pi^2 N}{\lambda} \sum^N_k a_k^2
\end{equation}
we see that the Vandermonde determinant gives the 2d Coulomb potential.
This partition function is indeed identified with that of a 2d Coulomb gas confined on a line,
with the repulsive electrostatic force and an attractive harmonic force \cite{Dyson:1962es}.
% Exact methods exist,
% such as the orthogonal polynomial method,
% to solve the spectral distribution.
% These allow physicists to compute observables exactly for $\mathcal{N}=4$ (cite Genis).
For $\mathcal{N}=2^*$, the matrix model is highly non-trivial,
but we can solve it systematically in the large $N$ limit,
where the saddle-point approximation and the continuous approximation in principle apply.
The only relevant quantity to compute then is the distribution of the eigenvalues:
\begin{equation} \label{def:rho}
\rho(x) = \dfrac{1}{N} \, \sum_{i=1}^N \delta(x-a_i) .
\end{equation}
It must have a compact support, i.e. $\rho(\pm \mu) = 0$,
where the endpoint $\mu$ determines the scale of the spontaneous symmetry breaking.
By definition, it is also unit-normalized:
\begin{equation}
\int_{-\mu}^\mu dx\, \rho(x) = 1.
\end{equation}
The saddle-point equation, from extremizing the effective action \eqref{eq:ZGUE} in terms of \eqref{def:rho},
is a singular (principal value) integral equation:
\begin{equation} \label{saddlepointEq}
\dfrac{\delta S [\rho]}{\delta \rho(x)} = 0 \quad
\Rightarrow \quad
\fint_{-\mu}^\mu dy \, K(x-y) \rho(y) = \dfrac{8\pi^2}{\lambda}x.
\end{equation}
The singular kernel for the GUE case is just the Hilbert kernel\footnote{
The name is in relation with the Hilbert transform.
It is also known as Cauchy kernel in the literature.},
that is
\begin{equation}
K_\text{Hilbert}(x)=\dfrac{1}{x}.
\end{equation}
In the Coulomb gas picture, the saddle-point equation determines the equilibrium distribution due to the force balance.
The result is the well-known Wigner's semicircle distribution
\begin{equation}\label{semicircle}
\rho(x) = \dfrac{2}{\pi \mu^2} \sqrt{\mu^2-x^2},
\quad \mu = \dfrac{\sqrt{\lambda}}{2\pi},
\end{equation}
shown in figure \ref{fig:semicircle}.
\begin{figure}[t]
\begin{center}
\centerline{\includegraphics[width=0.8\textwidth]{Images/semicircle.pdf}}
\caption{\label{fig:semicircle} Wigner's semicircle distribution, solution to the Gaussian unitary ensemble (GUE).}
\end{center}
\end{figure}
For the $\mathcal{N}=2^*$ SYM, the kernel is
\begin{equation}
K(x)=\dfrac{1}{x}-\mathcal{K}(x)+\dfrac{1}{2}\,\mathcal{K}(x+MR)+\dfrac{1}{2}\,\mathcal{K}(x-MR),
\end{equation}
where
\begin{equation}
\mathcal{K}(x) \equiv -\dfrac{H'(x)}{H(x)}
= 2x\sum_{n=1}^{\infty} \left(\dfrac{1}{n}-\dfrac{n}{n^2+x^2} \right),
\end{equation}
and much more interesting features show up in the saddle-point solution, as shown in figure \ref{fig:phaseDiagram}.
Let us briefly review these results.
In the strong-coupling regime, the bulk of the distribution is also a semicircle but with a rescaled endpoint:
\begin{equation}\label{semicircleN=2*}
\rho(x) = \dfrac{2}{\pi \mu^2} \sqrt{\mu^2-x^2},
\quad
\mu=\dfrac{\sqrt{\lambda (1+(MR)^2)}}{2\pi},
\quad (\lambda \rightarrow \infty).
\end{equation}
This is due to the fact that the kernel is approximately a Hilbert kernel \cite{Buchel:2013id}:
\begin{equation} \label{Kapprox}
K(x) \approx \dfrac{1+(MR)^2}{x}, \quad (\lambda \rightarrow \infty).
\end{equation}
Close to the edge-points, this approximation no longer holds,
and it was the goal of Paper I to find the endpoint distribution in the strong coupling regime.
We computed the endpoint distribution exactly using the so-called Wiener-Hopf method,
which is essentially the Fourier transform of the convolution integral in \eqref{saddlepointEq} in a semi-infinite interval
(zero being at the endpoint),
that relies on a certain factorization of the kernel.
The distribution exhibits oscillatory behavior with a period proportional to the scale $M R$.
In the decompactification limit $MR\rightarrow \infty$ (but $\mu\gg MR$ because we remain in the strong coupling limit),
the peaks of the oscillation diverge, see figure \ref{fig:phaseDiagram}.
The analytical endpoint distribution at strictly infinite coupling and flat space, with $\xi\equiv\mu-x$, is summarized below:
\begin{equation}
\rho(\xi )= \frac{2^{3/2}}{\pi \mu^{3/2}}
% \frac{\sqrt{2 M R}}{\pi \mu^{3/2}}
\begin{cases}
MR \sqrt{\xi},
&\quad (\xi \sim 1)\\
\dfrac{\sqrt{M R}}{2}\sum_{k=0}^{\left[\frac{\xi }{MR}\right]}
\left(\left\{\frac{\xi }{MR}\right\} + k\right)^{-1/2}
&\quad (\xi \sim M R),
\end{cases}
\end{equation}
where $[\cdot]$ and $\{\cdot\}$ denote the integer and the fractional part, respectively,
and $\mu=MR\sqrt{\lambda}/(2\pi)$, from \eqref{semicircleN=2*}.
Physically, the cusps appear due to a resonance phenomena
\begin{equation}
m_{ij} = |a_i-a_j \pm MR| \approx 0
\end{equation}
of very light states in the hypermultiplet sector.
Similar features were already observed for finite couplings in the flat space limit \cite{Russo:2013qaa},
and it was numerically shown that there are infinite-many critical couplings defined by
\begin{equation}
\mu = g(\lambda_c^{(n)}) M R, \quad g(\lambda_c^{(n)}) = \dfrac{n}{2}, \quad n=1,\ldots
\end{equation}
This means there are infinitely many phase transitions, where the phases are distinguished by the number of cusps of the distribution,
and the coupling $\lambda$ is the order parameter.
At strong coupling, the critical behavior persists and matches with the one obtained from the decompactification limit,
hence these two limits commute \cite{Zarembo:2014ooa}.
\begin{figure}[t]
\begin{center}
\centerline{\includegraphics[width=0.9\textwidth]{Images/phaseDiagram.pdf}}
\end{center}
\caption{\label{fig:phaseDiagram} Phase diagram for the partition function of $\mathcal{N}=2^*$ SYM on $S^4$, in the large $N$ limit.
The plots at the decompactification limit are taken from \cite{Russo:2013qaa}, and the ones at strong coupling limit are from Paper I, where only close to the endpoint is shown and $R=1$.
In the zero mass limit, we have $\mathcal{N}=4$ SYM, where the distribution is the Wigner semicircle for any coupling.}
\end{figure}
Such phase transitions are common among large-$N$ matrix models,
and have been observed in e.g. ABJM models \cite{Anderson:2014hxa}, 5d $\mathcal{N}=1$ SYM with massive matter multiplets \cite{Nedelin:2015mta}.
In our case, the gauge/string duality in principle gives us an opportunity to understand them from the point of view of gravity.
The physical observables we use to probe the infinite-coupling phase are Wilson loops, the topic of the next chapter.
|
{"hexsha": "f169b913dac53bf56299f2f74f754ad2402e5707", "size": 11872, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Chapters/PartitionFunctions.tex", "max_stars_repo_name": "yixinyi/PhDThesis", "max_stars_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapters/PartitionFunctions.tex", "max_issues_repo_name": "yixinyi/PhDThesis", "max_issues_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapters/PartitionFunctions.tex", "max_forks_repo_name": "yixinyi/PhDThesis", "max_forks_repo_head_hexsha": "fa5e6d89bf6e7658cebae8bab8a3d22fe4e53e29", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.3129770992, "max_line_length": 187, "alphanum_fraction": 0.7146226415, "num_tokens": 3785}
|
import os
import numpy as np
import pandas as pd
from time import time, sleep
from datetime import timedelta
from torch.utils.tensorboard import SummaryWriter
from tensorboard.backend.event_processing import event_accumulator
from tqdm import tqdm
from .algo.base import Algorithm
from .env import NormalizedEnv
class Trainer:
"""
Trainer for all the algorithms
Parameters
----------
env: NormalizedEnv
environment for training
env_test: NormalizedEnv
environment for testing
algo: Algorithm
the algorithm to be trained
log_dir: str
path to save logs
seed: int
random seed
num_steps: int
number of steps to train
eval_interval: int
time interval between evaluations
num_eval_episodes: int
number of episodes for evaluation
"""
def __init__(
self,
env: NormalizedEnv,
env_test: NormalizedEnv,
algo: Algorithm,
log_dir: str,
seed: int = 0,
num_steps: int = 10**5,
eval_interval: int = 10**3,
num_eval_episodes: int = 5
):
super().__init__()
# Env to collect samples.
self.env = env
self.env.seed(seed)
# Env for evaluation.
self.env_test = env_test
self.env_test.seed(2**31-seed)
self.algo = algo
self.log_dir = log_dir
# Log setting.
self.summary_dir = os.path.join(log_dir, 'summary')
self.writer = SummaryWriter(log_dir=self.summary_dir)
self.model_dir = os.path.join(log_dir, 'model')
if not os.path.exists(self.model_dir):
os.makedirs(self.model_dir)
# Other parameters.
self.num_steps = num_steps
self.eval_interval = eval_interval
self.num_eval_episodes = num_eval_episodes
def train(self):
"""Start training"""
# Time to start training.
self.start_time = time()
# Episode's timestep.
t = 0
# Initialize the environment.
state = self.env.reset()
for step in tqdm(range(1, self.num_steps + 1)):
# Pass to the algorithm to update state and episode timestep.
state, t = self.algo.step(self.env, state, t, step)
# Update the algorithm whenever ready.
if self.algo.is_update(step):
self.algo.update(self.writer)
# Evaluate regularly.
if step % self.eval_interval == 0:
self.evaluate(step)
self.algo.save_models(os.path.join(self.model_dir, f'step{step}'))
# Wait for the logging to be finished.
sleep(30)
# save rewards as csv
summary = event_accumulator.EventAccumulator(self.summary_dir)
summary.Reload()
returns = pd.DataFrame(summary.Scalars('return/test'))
returns.to_csv(os.path.join(self.log_dir, 'rewards.csv'), index=False)
sleep(30)
def evaluate(self, step: int):
"""
Evaluate the algorithm
Parameters
----------
step: int
current training step
"""
returns = []
# mean_return = 0.0
for _ in range(self.num_eval_episodes):
state = self.env_test.reset()
episode_return = 0.0
done = False
t = 0
while t < self.env.max_episode_steps:
action = self.algo.exploit(state)
state, reward, done, _ = self.env_test.step(action)
episode_return += reward
t += 1
if done:
break
returns.append(episode_return)
# mean_return += episode_return / self.num_eval_episodes
self.writer.add_scalar('return/test', np.mean(returns), step)
tqdm.write(f'Num steps: {step:<6}, '
f'Return: {np.mean(returns):<5.1f}, '
f'Min/Max Return: {np.min(returns):<5.1f}/{np.max(returns):<5.1f}, '
f'Time: {self.time}')
@property
def time(self):
"""Return current training time"""
return str(timedelta(seconds=int(time() - self.start_time)))
|
{"hexsha": "943401f914012a4379580df049f55bbdc68727cd", "size": 4385, "ext": "py", "lang": "Python", "max_stars_repo_path": "cail/trainer.py", "max_stars_repo_name": "Stanford-ILIAD/Confidence-Aware-Imitation-Learning", "max_stars_repo_head_hexsha": "1d8af0e4ab87a025885133a2384d5a937329b2f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2021-10-30T15:19:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T12:57:49.000Z", "max_issues_repo_path": "cail/trainer.py", "max_issues_repo_name": "syzhang092218-source/Confidence-Aware-Imitation-Learning", "max_issues_repo_head_hexsha": "1d8af0e4ab87a025885133a2384d5a937329b2f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cail/trainer.py", "max_forks_repo_name": "syzhang092218-source/Confidence-Aware-Imitation-Learning", "max_forks_repo_head_hexsha": "1d8af0e4ab87a025885133a2384d5a937329b2f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-29T11:28:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T14:12:47.000Z", "avg_line_length": 30.4513888889, "max_line_length": 88, "alphanum_fraction": 0.5548460661, "include": true, "reason": "import numpy", "num_tokens": 941}
|
#ifndef UNIT_TESTS_JSON_EQUAL
#define UNIT_TESTS_JSON_EQUAL
#include <boost/test/unit_test.hpp>
#include "osrm/json_container.hpp"
#include "util/json_deep_compare.hpp"
inline boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference,
const osrm::util::json::Value &result)
{
std::string reason;
auto is_same = osrm::util::json::compare(reference, result, reason);
if (!is_same)
{
boost::test_tools::predicate_result res(false);
res.message() << reason;
return res;
}
return true;
}
#define CHECK_EQUAL_JSON(reference, result) BOOST_CHECK(compareJSON(reference, result));
#endif
|
{"hexsha": "1453086e0dec6448a76a8f89c922844516369ebe", "size": 721, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "unit_tests/library/equal_json.hpp", "max_stars_repo_name": "jhermsmeier/osrm-backend", "max_stars_repo_head_hexsha": "7b11cd3a11c939c957eeff71af7feddaa86e7f82", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 4526.0, "max_stars_repo_stars_event_min_datetime": "2015-01-01T15:31:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:33:49.000Z", "max_issues_repo_path": "unit_tests/library/equal_json.hpp", "max_issues_repo_name": "serarca/osrm-backend", "max_issues_repo_head_hexsha": "3b4e2e83ef85983df1381dbeacd0ea5d4b9bbbcb", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4497.0, "max_issues_repo_issues_event_min_datetime": "2015-01-01T15:29:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T19:19:35.000Z", "max_forks_repo_path": "unit_tests/library/equal_json.hpp", "max_forks_repo_name": "serarca/osrm-backend", "max_forks_repo_head_hexsha": "3b4e2e83ef85983df1381dbeacd0ea5d4b9bbbcb", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 3023.0, "max_forks_repo_forks_event_min_datetime": "2015-01-01T18:40:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T13:30:46.000Z", "avg_line_length": 24.8620689655, "max_line_length": 96, "alphanum_fraction": 0.6601941748, "num_tokens": 152}
|
#!/usr/local/bin/python
"""
***********************************************
- PROGRAM: matrix2tab.py
- CONTACT: Bryan lajoie (bryan.lajoie@umassmed.edu)
***********************************************
"""
from __future__ import print_function
from __future__ import division
import numpy as np
import scipy as sp
import pdb
import h5py
import sys
import argparse
import logging
import time
import shutil
import gzip
import re
import os
import math
import uuid
import socket
import itertools
import collections
from datetime import datetime
import re
import os
# deprecated from scipy and unusde in the script:
# from scipy.stats.stats import nanmean
import numpy as np
import scipy as sp
# For eigenvectors and eigenvalues
from scipy import linalg as la
from math import cos,log,sin,sqrt
# deprecated from scipy and unusde in the script:
# from scipy import weave
verboseprint=lambda *a, **k: None
__version__ = "1.0"
def main():
print("")
parser=argparse.ArgumentParser (description='convert a cworld/my5C fomatted tsv matrix file to a 3 col tab matrix [symmetrical only]',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i',dest='inputMatrix',type=str,required=True,help='interaction matrix hdf5 file')
parser.add_argument('-v', '--verbose', dest='verbose', action='count', help='Increase verbosity (specify multiple times for more)')
args=parser.parse_args()
inputMatrix=args.inputMatrix
verbose=args.verbose
log_level = logging.WARNING
if verbose == 1:
log_level = logging.INFO
elif verbose >= 2:
log_level = logging.DEBUG
logging.basicConfig(level=log_level)
global verboseprint
verboseprint = print if verbose else lambda *a, **k: None
if not os.path.isfile(inputMatrix):
sys.exit('invalid input file! (non-existant)')
scriptPath=os.path.realpath(__file__)
scriptPath="/".join(scriptPath.split("/")[0:-2])
verboseprint("inputMatrix",inputMatrix)
inputMatrix_name=os.path.basename(inputMatrix)
inputMatrix_name=re.sub(".gz", "", inputMatrix_name)
inputMatrix_name=re.sub(".matrix", "", inputMatrix_name)
verboseprint("inputMatrix_name",inputMatrix_name)
verboseprint("")
verboseprint("loading matrix ... ",end="")
if inputMatrix.endswith('.gz'):
infh=gzip.open(inputMatrix,'r')
else:
infh=open(inputMatrix,'r')
matrix,header_rows,header_cols = load_matrix((l for l in infh if not l.startswith('#')), hrows=1, hcols=1) # since this returns data, header_rows and header_cols
infh.close()
verboseprint("done")
verboseprint("")
# get number of rows/col (assuming symmetrical)
nrows=len(header_rows)
ncols=len(header_cols)
nmatrix_rows=matrix.shape[0]
nmatrix_cols=matrix.shape[1]
verboseprint("rows:",nrows,nmatrix_rows)
verboseprint("cols:",ncols,nmatrix_cols)
if(nrows != ncols):
sys.exit('non-symmetrical matrix!')
if(nmatrix_rows != nmatrix_cols):
sys.exit('non-symmetrical matrix!')
if(nrows != nmatrix_rows):
sys.exit('non-symmetrical matrix!')
if(ncols != nmatrix_cols):
sys.exit('non-symmetrical matrix!')
assembly=getHeaderAssembly(header_rows)
equalSpacingFlag,equalSizingFlag,header_spacing,header_sizing=getHeaderSpacing(header_rows)
num_headers=len(header_rows)
verboseprint("")
matrixFile=inputMatrix_name+".tab.gz"
writeTab(header_rows,matrix,matrixFile)
def getHeaderAssembly(header_rows):
assembly=None
for i,header in enumerate(header_rows):
m=re.search(r'(\S+)\|(\S+)\|(\S+):(\d+)-(\d+)',header)
if m==None:
sys.exit('error: incorrect input format!')
bin_id,genome,chr_id,bin_start,bin_end=m.groups()
if assembly==None:
assembly=genome
else:
if assembly!=genome:
sys.exit('assembly/genome is not constant!')
assembly=genome
return(assembly)
def getHeaderSpacing(header_rows):
globalHeaderSpacingArr=[]
globalHeaderSizingArr=[]
equalSpacingFlag=1
equalSizingFlag=1
bin_size=None
bin_step=None
globalHeaderSpacing=globalHeaderSizing=-1
for i in xrange(len(header_rows)-1):
header=header_rows[i]
headerObject=getHeaderObject(header)
headerRegion=headerObject["region"]
headerStart=headerObject["start"]
headerEnd=headerObject["end"]
headerSize=headerObject["size"]
nextHeader=header_rows[i+1]
nextHeaderObject=getHeaderObject(nextHeader)
nextHeaderRegion=nextHeaderObject["region"]
nextHeaderStart=nextHeaderObject["start"]
nextHeaderEnd=nextHeaderObject["end"]
nextHeaderSize=nextHeaderObject["size"]
if((nextHeaderRegion != headerRegion) or (headerEnd == nextHeaderEnd) or (headerStart == nextHeaderStart)):
continue
if((globalHeaderSpacing != ((nextHeaderStart-headerStart))) and (globalHeaderSpacing != -1)):
equalSpacingFlag=0
if((globalHeaderSizing != (headerSize)) and (globalHeaderSizing != -1)):
equalSizingFlag=0
globalHeaderSpacing=(nextHeaderStart-headerStart)
globalHeaderSizing=headerSize
globalHeaderSpacingArr.append(globalHeaderSpacing)
globalHeaderSizingArr.append(globalHeaderSizing)
meanGlobalHeaderSpacing=int(np.mean(globalHeaderSpacingArr))
meanGlobalHeaderSizing=int(np.mean(globalHeaderSizingArr))
return(equalSpacingFlag,equalSizingFlag,meanGlobalHeaderSpacing,meanGlobalHeaderSizing)
def input_wrapper(infile):
if infile.endswith('.gz'):
fh=gzip.open(infile,'r')
else:
fh=open(infile,'r')
return fh
def output_wrapper(outfile,append=False,suppress_comments=False):
if outfile.endswith('.gz'):
if append:
fh=gzip.open(outfile,'a')
else:
fh=gzip.open(outfile,'w')
else:
if append:
fh=open(outfile,'a')
else:
fh=open(outfile,'w')
# disable comment(s)if (UCSC format file)
if outfile.endswith('.bed'):
suppress_comments = True
if outfile.endswith('.bed.gz'):
suppress_comments = True
if outfile.endswith('.bedGraph'):
suppress_comments = True
if outfile.endswith('.bedGraph.gz'):
suppress_comments = True
if outfile.endswith('.wig'):
suppress_comments = True
if outfile.endswith('.wig.gz'):
suppress_comments = True
if outfile.endswith('.sam'):
suppress_comments = True
if outfile.endswith('.sam.gz'):
suppress_comments = True
if outfile.endswith('.bam'):
suppress_comments = True
if outfile.endswith('.fastq'):
suppress_comments = True
if outfile.endswith('.fastq.gz'):
suppress_comments = True
if not suppress_comments:
print("## ",os.path.basename(__file__),sep="",file=fh)
print("## ",sep="",file=fh)
print("## Dekker Lab",sep="",file=fh)
print("## Contact: Bryan R. Lajoie",sep="",file=fh)
print("## https://github.com/blajoie",sep="",file=fh)
print("## ",sep="",file=fh)
print("## Version:\t",__version__,sep="",file=fh)
print("## Date:\t",get_date(),sep="",file=fh)
print("## Host:\t",get_compute_resource(),sep="",file=fh)
return(fh)
def get_date():
time=datetime.now()
date=time.strftime('%I:%M:%S %p, %m/%d/%Y')
return date
def get_compute_resource():
return(socket.gethostname())
def deGroupChr(chr_id):
return(chr_id.split('-')[0])
def getHeaderObject(header,enforceValidHeaders=0):
subName=assembly=coords=None
tmp=header.split('|')
if enforceValidHeaders and len(tmp) != 3:
sys.exit('error: incorrect input format!')
subName,assembly,coords=tmp
chromosome=pos=None
tmp=coords.split(':')
if enforceValidHeaders and len(tmp) != 2:
sys.exit('error: incorrect input format!')
chromosome,pos=tmp
region=chromosome
primerType=fragmentNumber=None
if("__" in subName):
tmp=subName.split("__")
region=tmp
else:
tmp=subName.split("_")
if(len(tmp) == 5 and tmp[0] == "5C"):
region=str(tmp[1])+"_"+str(tmp[2])
primerType=int(tmp[3])
fragmentNumber=int(tmp[4])
start=end=None
tmp=pos.split("-")
if enforceValidHeaders and len(tmp) != 2:
sys.exit('error: incorrect input format!')
start=int(tmp[0])
end=int(tmp[1])
size=((end-start)+1) # add to for 1-based positioning
midpoint=((end+start)/2)
headerObject=dict()
headerObject["subName"]=subName
headerObject["fragmentNumber"]=fragmentNumber
headerObject["primerType"]=primerType
headerObject["assembly"]=assembly
headerObject["chromosome"]=chromosome
headerObject["coords"]=coords
headerObject["region"]=region
headerObject["start"]=start
headerObject["end"]=end
headerObject["midpoint"]=midpoint
headerObject["size"]=size
return(headerObject)
def headers2tabs(headers):
header_tabs=[]
for i in headers:
header_object=getHeaderObject(i)
header_tabs.append([header_object["chromosome"],header_object["start"],header_object["end"]])
return np.array(header_tabs)
def writeTab(header_rows,matrix,matrixFile,precision=4):
"""
write a np matrix into tab 3-col matrix format
"""
nrows=len(header_rows)
header_tabs=headers2tabs(header_rows)
# interaction matrix output
out_fh=gzip.open(matrixFile,"wb")
format_func=("{:0."+str(precision)+"f}").format
k=0
for i in xrange(nrows):
print("\t".join(header_tabs[i])+"\t"+"\t".join(map(format_func,matrix[i,:])),file=out_fh)
out_fh.close()
def writeMatrix(header_rows,header_cols,matrix,matrixFile,precision=4):
"""
write a np matrix with row/col headers - my5C file format - txt formatted gzipped file
"""
nrows=len(header_rows)
ncols=len(header_cols)
# interaction matrix output
out_fh=gzip.open(matrixFile,"wb")
# write matrix col headers
header=[str(i) for i in header_cols]
print(str(nrows)+"x"+str(ncols)+"\t"+"\t".join(header),file=out_fh)
format_func=("{:0."+str(precision)+"f}").format
k=0
for i in xrange(nrows):
print(header_rows[i]+"\t"+"\t".join(map(format_func,matrix[i,:])),file=out_fh)
out_fh.close()
def load_matrix(fh,hrows=0,hcols=0,np_dtype='float32',row_block_size=1000,numpy_mode=True,max_rows=None,verbose=False,return_all=False,pad=None):
"""
load a np.array or a list of lists from a text file handle (but works with any iterator) or filename, more memory efficient than numpy.genfromtxt(), headers are returned as lists of strings
"""
fh_from_filename=False
if type(fh)==str:
if (fh=='-'):
fh=sys.stdin
else:
fh=open(fh,'r')
fh_from_filename=True
original_fh=fh
# init
firstline=fh.next()
fh=itertools.chain([firstline],fh)
cols=len(firstline.rstrip("\n").split("\t"))
rows=row_block_size
if (max_rows!=None and max_rows<row_block_size):
rows=max_rows
if(hcols):
cols-=hcols
if numpy_mode:
data=np.zeros((rows,cols),dtype=np_dtype)
else:
data=[]
header_rows=[[] for i in range(hrows)]
for i in range(hrows):
header_rows[i]=fh.next().rstrip("\n").split("\t")[hcols:]
header_cols=[[] for i in range(hcols)]
# fill one line at a time
prev_cols=-1
r=0
if (max_rows==None or r<max_rows):
for i in fh:
line=i.rstrip("\n").split("\t")
cols=len(line)-hcols
# if(cols==0):
# sys.exit('no valid columns in input line '+str(r))
if(prev_cols>-1 and cols!=prev_cols):
if(pad and cols<prev_cols):
line=line+['']*(prev_cols-cols)
cols=len(line)-hcols
else:
sys.exit('inconsistent number of columns in input line '+str(r))
prev_cols=cols
if numpy_mode:
not_allowed = ['','NA']
try: # if np_dtype does not except ''or 'NA' as a value
np.dtype(np_dtype).type(not_allowed)
except ValueError:
try:
np.dtype(np_dtype).type('nan')
line=[('nan' if i in not_allowed else i) for i in line] # '' or 'NA' are replaced with 'nan'
except ValueError:
pass
for j in range(hcols):
header_cols[j].append(line[j])
if numpy_mode:
data[r,:]=line[hcols:]
# enlarge data if needed
if(r==(data.shape[0]-1)):
data=np.resize(data,(data.shape[0]+row_block_size,cols))
rows=data.shape[0]
else:
data.append(line[hcols:])
r+=1
if (max_rows!=None and r>=max_rows):
break
rows=r
if numpy_mode:
data=np.resize(data,(rows,cols))
if (fh_from_filename):
original_fh.close()
if (hcols==1):
header_cols=header_cols[0]
if (hrows==1):
header_rows=header_rows[0]
if(verbose):
sys.stderr.write("loaded matrix with dimensions ("+str(len(data))+","+str(cols)+")\n")
if (return_all or (hrows and hcols)):
return data,header_rows,header_cols
if(hrows):
return data,header_rows
if(hcols):
return data,header_cols
return data
if __name__=="__main__":
main()
|
{"hexsha": "e060efb3b5ae045ae97d60ab195831989417a867", "size": 14297, "ext": "py", "lang": "Python", "max_stars_repo_path": "scripts/python/matrix2tab.py", "max_stars_repo_name": "sergpolly/cworld-dekker", "max_stars_repo_head_hexsha": "7557bbe873e623e9059482722922faca4e784ad0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 43, "max_stars_repo_stars_event_min_datetime": "2016-10-28T06:24:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T09:39:23.000Z", "max_issues_repo_path": "scripts/python/matrix2tab.py", "max_issues_repo_name": "sergpolly/cworld-dekker", "max_issues_repo_head_hexsha": "7557bbe873e623e9059482722922faca4e784ad0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 13, "max_issues_repo_issues_event_min_datetime": "2017-12-02T20:00:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-18T16:28:34.000Z", "max_forks_repo_path": "scripts/python/matrix2tab.py", "max_forks_repo_name": "sergpolly/cworld-dekker", "max_forks_repo_head_hexsha": "7557bbe873e623e9059482722922faca4e784ad0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2016-12-05T06:03:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T12:43:03.000Z", "avg_line_length": 28.8828282828, "max_line_length": 195, "alphanum_fraction": 0.6064908722, "include": true, "reason": "import numpy,import scipy,from scipy", "num_tokens": 3390}
|
#!/bin/python
# This script will ...
#
#
#
# TO DO: annotation paths are hard coded and if two-sided or one-sided p-values are also hard coded
#
#
# Abin Abraham
# created on: 2020-01-05 08:20:56
import os
import sys
import numpy as np
import pandas as pd
import pickle
from .helper_general import safe_mkdir
from datetime import datetime
DATE = datetime.now().strftime('%Y-%m-%d')
import logging
logger = logging.getLogger("main.{}".format(__name__))
# -----------
# FUNCTIONS
# -----------
# %%
# -----------
# MAIN
# -----------
def calc_genome_distribution_of_annotations(anno_path_dict, anno_summary_dir):
logger.info(f"Calculating the genome-wide summary of evolutionary annotations.")
safe_mkdir(anno_summary_dir)
all_summary_df = pd.DataFrame()
for this_anno, anno_file in anno_path_dict.items():
logger.debug("Calculating genome summary for {}.".format(this_anno))
anno = pickle.load(open(anno_file, "rb"))
anno_df = pd.DataFrame.from_dict(anno, orient="index")
anno_df.columns = ["value"]
max = anno_df.max()[0]
min = anno_df.min()[0]
mean = anno_df.mean()[0]
median = anno_df.median()[0]
std = anno_df.std()[0]
q25 = anno_df.quantile(0.25)[0]
q75 = anno_df.quantile(0.75)[0]
q95 = anno_df.quantile(0.95)[0]
q5 = anno_df.quantile(0.05)[0]
this_summary_df = pd.DataFrame(
{
"annotation": [this_anno],
"max": [max],
"min": [min],
"mean": [mean],
"median": [median],
"std": [std],
"q25": [q25],
"q75": [q75],
"q95": [q95],
"q5": [q5],
}
)
all_summary_df = all_summary_df.append(this_summary_df)
anno_genom_summary_file = os.path.join(anno_summary_dir, 'genome_wide_summary_of_annotations.tsv')
all_summary_df.to_csv(anno_genom_summary_file, sep="\t", index=False)
logger.debug(f"[status] Wrote the genome-wide summary of evolutionary annotations.")
return anno_genom_summary_file
|
{"hexsha": "7804716456647ec213df03a29488ce0f81fe474b", "size": 2158, "ext": "py", "lang": "Python", "max_stars_repo_path": "gsel_vec/scripts/helper_calc_genome_distribution_of_annotations.py", "max_stars_repo_name": "abraham-abin13/gsel_vec", "max_stars_repo_head_hexsha": "486baa867f95f1d9d106e59a00e408d14ac42271", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-07-22T23:14:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-22T23:14:33.000Z", "max_issues_repo_path": "gsel_vec/scripts/helper_calc_genome_distribution_of_annotations.py", "max_issues_repo_name": "abraham-abin13/gsel_vec", "max_issues_repo_head_hexsha": "486baa867f95f1d9d106e59a00e408d14ac42271", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gsel_vec/scripts/helper_calc_genome_distribution_of_annotations.py", "max_forks_repo_name": "abraham-abin13/gsel_vec", "max_forks_repo_head_hexsha": "486baa867f95f1d9d106e59a00e408d14ac42271", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0930232558, "max_line_length": 105, "alphanum_fraction": 0.593141798, "include": true, "reason": "import numpy", "num_tokens": 539}
|
[STATEMENT]
lemma reduce_system_matrix_signs_helper_aux_R:
fixes p:: "real poly"
fixes qs :: "real poly list"
fixes subsets :: "(nat list*nat list) list"
fixes signs :: "rat list list"
fixes S:: "nat list"
assumes well_def_h: "\<forall>x. List.member S x \<longrightarrow> x < length signs"
assumes nonzero: "p \<noteq> 0"
shows "alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
[PROOF STEP]
have h0a: "dim_col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) = length (take_indices signs S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. dim_col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) = length (take_indices signs S)
[PROOF STEP]
unfolding take_cols_from_matrix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. dim_col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (take_indices (cols (alt_matrix_A_R signs subsets)) S)) = length (take_indices signs S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. length (take_indices (cols (alt_matrix_A_R signs subsets)) S) = length (take_indices signs S)
[PROOF STEP]
unfolding take_indices_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. length (map ((!) (cols (alt_matrix_A_R signs subsets))) S) = length (map ((!) signs) S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) = length (take_indices signs S)
goal (1 subgoal):
1. alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
[PROOF STEP]
have h0: "\<forall>i < length (take_indices signs S). (col (alt_matrix_A_R (take_indices signs S) subsets ) i =
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<forall>i<length (take_indices signs S). col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
proof clarsimp
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
assume asm: "i < length (take_indices signs S)"
[PROOF STATE]
proof (state)
this:
i < length (take_indices signs S)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have i_lt: "i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
i < length (take_indices signs S)
goal (1 subgoal):
1. i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. i < length (take_indices signs S) \<Longrightarrow> i < length S
[PROOF STEP]
unfolding take_indices_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. i < length (map ((!) signs) S) \<Longrightarrow> i < length S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have h0: " vec (length subsets) (\<lambda>j. z_R (subsets ! j) (map ((!) signs) S ! i)) =
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vec (length subsets) (\<lambda>j. z_R (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i)))
[PROOF STEP]
using nth_map
[PROOF STATE]
proof (prove)
using this:
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)
goal (1 subgoal):
1. vec (length subsets) (\<lambda>j. z_R (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i)))
[PROOF STEP]
by (metis \<open>i < length (take_indices signs S)\<close> length_map take_indices_def)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i)))
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have dim: "(map ((!) (cols (alt_matrix_A_R signs subsets))) S) ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
have "dim_col (alt_matrix_A_R signs subsets) = length (signs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. dim_col (alt_matrix_A_R signs subsets) = length signs
[PROOF STEP]
by (simp add: alt_matrix_A_R_def)
[PROOF STATE]
proof (state)
this:
dim_col (alt_matrix_A_R signs subsets) = length signs
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
have well_d: "S ! i < length (signs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. S ! i < length signs
[PROOF STEP]
using well_def_h
[PROOF STATE]
proof (prove)
using this:
\<forall>x. List.member S x \<longrightarrow> x < length signs
goal (1 subgoal):
1. S ! i < length signs
[PROOF STEP]
using i_lt in_set_member
[PROOF STATE]
proof (prove)
using this:
\<forall>x. List.member S x \<longrightarrow> x < length signs
i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
(?x \<in> set ?xs) = List.member ?xs ?x
goal (1 subgoal):
1. S ! i < length signs
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
S ! i < length signs
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
have
map_eq: "(map ((!) (cols (alt_matrix_A_R signs subsets))) S) ! i = nth (cols (alt_matrix_A_R signs subsets)) (S ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i = cols (alt_matrix_A_R signs subsets) ! (S ! i)
[PROOF STEP]
using i_lt
[PROOF STATE]
proof (prove)
using this:
i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i = cols (alt_matrix_A_R signs subsets) ! (S ! i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i = cols (alt_matrix_A_R signs subsets) ! (S ! i)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
have "nth (cols (alt_matrix_A_R signs subsets)) (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
using col_dim
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)
goal (1 subgoal):
1. cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
unfolding cols_def
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)
goal (1 subgoal):
1. map (col (alt_matrix_A_R signs subsets)) [0..<dim_col (alt_matrix_A_R signs subsets)] ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
using nth_map well_d
[PROOF STATE]
proof (prove)
using this:
col ?A ?i \<in> carrier_vec (dim_row ?A)
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)
S ! i < length signs
goal (1 subgoal):
1. map (col (alt_matrix_A_R signs subsets)) [0..<dim_col (alt_matrix_A_R signs subsets)] ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
by (simp add: \<open>dim_col (alt_matrix_A_R signs subsets) = length signs\<close>)
[PROOF STATE]
proof (state)
this:
cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
using map_eq
[PROOF STATE]
proof (prove)
using this:
cols (alt_matrix_A_R signs subsets) ! (S ! i) \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i = cols (alt_matrix_A_R signs subsets) ! (S ! i)
goal (1 subgoal):
1. map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have h1: "col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i =
col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i
[PROOF STEP]
by (simp add: take_cols_from_matrix_def take_indices_def)
[PROOF STATE]
proof (state)
this:
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have h2: "col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i
= nth (map ((!) (cols (alt_matrix_A_R signs subsets))) S) i "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i
[PROOF STEP]
using dim i_lt asm col_mat_of_cols[where j = "i", where n = "(dim_row (alt_matrix_A_R signs subsets))",
where vs = "(map ((!) (cols (alt_matrix_A_R signs subsets))) S)"]
[PROOF STATE]
proof (prove)
using this:
map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))
i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S)
i < length (take_indices signs S)
\<lbrakk>i < length (map ((!) (cols (alt_matrix_A_R signs subsets))) S); map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i \<in> carrier_vec (dim_row (alt_matrix_A_R signs subsets))\<rbrakk> \<Longrightarrow> col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i
goal (1 subgoal):
1. col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have h3: "col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = (col (alt_matrix_A_R signs subsets) (S !i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (alt_matrix_A_R signs subsets) (S ! i)
[PROOF STEP]
using h1 h2
[PROOF STATE]
proof (prove)
using this:
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i
col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i
goal (1 subgoal):
1. col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (alt_matrix_A_R signs subsets) (S ! i)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i; col (mat_of_cols (dim_row (alt_matrix_A_R signs subsets)) (map ((!) (cols (alt_matrix_A_R signs subsets))) S)) i = map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i\<rbrakk> \<Longrightarrow> map ((!) (cols (alt_matrix_A_R signs subsets))) S ! i = col (alt_matrix_A_R signs subsets) (S ! i)
[PROOF STEP]
by (metis alt_matrix_char_R asm cols_nth dim_col_mat(1) in_set_member length_map mat_of_rows_list_def matrix_A_R_def nth_map nth_mem take_indices_def well_def_h)
[PROOF STATE]
proof (state)
this:
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (alt_matrix_A_R signs subsets) (S ! i)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
have "vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = (col (alt_matrix_A_R signs subsets) (S !i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A_R signs subsets) (S ! i)
[PROOF STEP]
by (metis asm in_set_member length_map nth_mem signs_are_cols_R take_indices_def well_def_h)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A_R signs subsets) (S ! i)
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A_R signs subsets) (S ! i)
[PROOF STEP]
have "vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) =
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i "
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A_R signs subsets) (S ! i)
goal (1 subgoal):
1. vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
using h0 h3
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i))) = col (alt_matrix_A_R signs subsets) (S ! i)
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (map ((!) signs) S ! i)) = vec (length subsets) (\<lambda>j. z_R (subsets ! j) (signs ! (S ! i)))
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i = col (alt_matrix_A_R signs subsets) (S ! i)
goal (1 subgoal):
1. vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
by (simp add: take_indices_def)
[PROOF STATE]
proof (state)
this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
goal (1 subgoal):
1. \<And>i. i < length (take_indices signs S) \<Longrightarrow> col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
show "col (alt_matrix_A_R (take_indices signs S) subsets) i =
col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i "
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
goal (1 subgoal):
1. col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
using asm signs_are_cols_R[where signs = "(take_indices signs S)", where subsets = "subsets"]
[PROOF STATE]
proof (prove)
using this:
vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i)) = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
i < length (take_indices signs S)
\<forall>i<length (take_indices signs S). col (alt_matrix_A_R (take_indices signs S) subsets) i = vec (length subsets) (\<lambda>j. z_R (subsets ! j) (take_indices signs S ! i))
goal (1 subgoal):
1. col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
goal (1 subgoal):
1. alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length (take_indices signs S). col (alt_matrix_A_R (take_indices signs S) subsets) i = col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) i
goal (1 subgoal):
1. alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
[PROOF STEP]
unfolding alt_matrix_A_R_def take_cols_from_matrix_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length (take_indices signs S). col (mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z_R (subsets ! i) (take_indices signs S ! j))) i = col (mat_of_cols (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)) i
goal (1 subgoal):
1. mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z_R (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<forall>i<length (take_indices signs S). vec (length subsets) (\<lambda>ia. z_R (subsets ! ia) (take_indices signs S ! i)) = col (mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)) i \<Longrightarrow> mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z_R (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
using h0a mat_col_eqI
[PROOF STATE]
proof (prove)
using this:
dim_col (take_cols_from_matrix (alt_matrix_A_R signs subsets) S) = length (take_indices signs S)
\<lbrakk>\<And>i. i < dim_col ?B \<Longrightarrow> col ?A i = col ?B i; dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B\<rbrakk> \<Longrightarrow> ?A = ?B
goal (1 subgoal):
1. \<forall>i<length (take_indices signs S). vec (length subsets) (\<lambda>ia. z_R (subsets ! ia) (take_indices signs S ! i)) = col (mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)) i \<Longrightarrow> mat (length subsets) (length (take_indices signs S)) (\<lambda>(i, j). z_R (subsets ! i) (take_indices signs S ! j)) = mat_of_cols (length subsets) (take_indices (cols (mat (length subsets) (length signs) (\<lambda>(i, j). z_R (subsets ! i) (signs ! j)))) S)
[PROOF STEP]
by (metis alt_matrix_A_R_def dim_col_mat(1) dim_row_mat(1) h0 mat_of_cols_def take_cols_from_matrix_def)
[PROOF STATE]
proof (state)
this:
alt_matrix_A_R (take_indices signs S) subsets = take_cols_from_matrix (alt_matrix_A_R signs subsets) S
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 9144, "file": "BenOr_Kozen_Reif_Renegar_Proofs", "length": 66}
|
theory Semantics
imports Main
begin
section {* The Language *}
subsection {* Variables and Values *}
type_synonym vname = string -- "names for variables"
datatype val
= Bool bool -- "Boolean value"
| Intg int -- "integer value"
abbreviation "true == Bool True"
abbreviation "false == Bool False"
subsection {* Expressions and Commands*}
datatype bop = Eq | And | Less | Add | Sub -- "names of binary operations"
datatype expr
= Val val -- "value"
| Var vname -- "local variable"
| BinOp expr bop expr ("_ \<guillemotleft>_\<guillemotright> _" [80,0,81] 80) -- "binary operation"
text {* Note: we assume that only type correct expressions are regarded
as later proofs fail if expressions evaluate to None due to type errors.
However there is [yet] no typing system *}
fun binop :: "bop \<Rightarrow> val \<Rightarrow> val \<Rightarrow> val option"
where "binop Eq v\<^sub>1 v\<^sub>2 = Some(Bool(v\<^sub>1 = v\<^sub>2))"
| "binop And (Bool b\<^sub>1) (Bool b\<^sub>2) = Some(Bool(b\<^sub>1 \<and> b\<^sub>2))"
| "binop Less (Intg i\<^sub>1) (Intg i\<^sub>2) = Some(Bool(i\<^sub>1 < i\<^sub>2))"
| "binop Add (Intg i\<^sub>1) (Intg i\<^sub>2) = Some(Intg(i\<^sub>1 + i\<^sub>2))"
| "binop Sub (Intg i\<^sub>1) (Intg i\<^sub>2) = Some(Intg(i\<^sub>1 - i\<^sub>2))"
| "binop bop v\<^sub>1 v\<^sub>2 = Some(Intg(0))"
datatype com
= Skip
| LAss vname expr ("_:=_" [70,70] 70) -- "local assignment"
| Seq com com ("_;;/ _" [61,60] 60)
| Cond expr com com ("if '(_') _/ else _" [80,79,79] 70)
| While expr com ("while '(_') _" [80,79] 70)
fun fv :: "expr \<Rightarrow> vname set" --"free variables in an expression"
where
FVc: "fv (Val V) = {}"
| FVv: "fv (Var V) = {V}"
| FVe: "fv (e1 \<guillemotleft>bop\<guillemotright> e2) = fv e1 \<union> fv e2"
subsection {* State *}
type_synonym state = "vname \<rightharpoonup> val"
text {* @{text interpret} silently assumes type correct expressions,
i.e. no expression evaluates to None *}
fun "interpret" :: "expr \<Rightarrow> state \<Rightarrow> val option" ("\<lbrakk>_\<rbrakk>_")
where Val: "\<lbrakk>Val v\<rbrakk> s = Some v"
| Var: "\<lbrakk>Var V\<rbrakk> s = s V"
| BinOp: "\<lbrakk>e\<^sub>1\<guillemotleft>bop\<guillemotright>e\<^sub>2\<rbrakk> s = (case \<lbrakk>e\<^sub>1\<rbrakk> s of None \<Rightarrow> None
| Some v\<^sub>1 \<Rightarrow> (case \<lbrakk>e\<^sub>2\<rbrakk> s of None \<Rightarrow> None
| Some v\<^sub>2 \<Rightarrow> binop bop v\<^sub>1 v\<^sub>2))"
subsection {* Small Step Semantics *}
inductive red :: "com * state \<Rightarrow> com * state \<Rightarrow> bool"
and red' :: "com \<Rightarrow> state \<Rightarrow> com \<Rightarrow> state \<Rightarrow> bool"
("((1\<langle>_,/_\<rangle>) \<rightarrow>/ (1\<langle>_,/_\<rangle>))" [0,0,0,0] 81)
where
"\<langle>c1,s1\<rangle> \<rightarrow> \<langle>c2,s2\<rangle> == red (c1,s1) (c2,s2)" |
RedLAss:
"\<langle>V:=e,s\<rangle> \<rightarrow> \<langle>Skip,s(V:=(\<lbrakk>e\<rbrakk> s))\<rangle>"
| SeqRed:
"\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s'\<rangle> \<Longrightarrow> \<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c\<^sub>1';;c\<^sub>2,s'\<rangle>"
| RedSeq:
"\<langle>Skip;;c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c\<^sub>2,s\<rangle>"
| RedCondTrue:
"\<lbrakk>b\<rbrakk> s = Some true \<Longrightarrow> \<langle>if (b) c\<^sub>1 else c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c\<^sub>1,s\<rangle>"
| RedCondFalse:
"\<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> \<langle>if (b) c\<^sub>1 else c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c\<^sub>2,s\<rangle>"
| RedWhileTrue:
"\<lbrakk>b\<rbrakk> s = Some true \<Longrightarrow> \<langle>while (b) c,s\<rangle> \<rightarrow> \<langle>c;;while (b) c,s\<rangle>"
| RedWhileFalse:
"\<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> \<langle>while (b) c,s\<rangle> \<rightarrow> \<langle>Skip,s\<rangle>"
lemmas red_induct = red.induct[split_format (complete)]
abbreviation reds ::"com \<Rightarrow> state \<Rightarrow> com \<Rightarrow> state \<Rightarrow> bool"
("((1\<langle>_,/_\<rangle>) \<rightarrow>*/ (1\<langle>_,/_\<rangle>))" [0,0,0,0] 81) where
"\<langle>c,s\<rangle> \<rightarrow>* \<langle>c',s'\<rangle> == red\<^sup>*\<^sup>* (c,s) (c',s')"
lemma Skip_reds:
"\<langle>Skip,s\<rangle> \<rightarrow>* \<langle>c',s'\<rangle> \<Longrightarrow> s = s' \<and> c' = Skip"
by(blast elim:converse_rtranclpE red.cases)
lemma LAss_reds:
"\<langle>V:=e,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> s' = s(V:=\<lbrakk>e\<rbrakk> s)"
proof(induct "V:=e" s rule:converse_rtranclp_induct2)
case (step s c'' s'')
hence "c'' = Skip" and "s'' = s(V:=(\<lbrakk>e\<rbrakk> s))" by(auto elim:red.cases)
with `\<langle>c'',s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>` show ?case by(auto dest:Skip_reds)
qed
lemma Seq2_reds:
"\<langle>Skip;;c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<langle>c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
by(induct c=="Skip;;c\<^sub>2" s rule:converse_rtranclp_induct2)(auto elim:red.cases)
lemma Seq_reds:
assumes "\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
obtains s'' where "\<langle>c\<^sub>1,s\<rangle> \<rightarrow>* \<langle>Skip,s''\<rangle>" and "\<langle>c\<^sub>2,s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
proof -
have "\<exists>s''. \<langle>c\<^sub>1,s\<rangle> \<rightarrow>* \<langle>Skip,s''\<rangle> \<and> \<langle>c\<^sub>2,s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
proof -
{ fix c c'
assume "\<langle>c,s\<rangle> \<rightarrow>* \<langle>c',s'\<rangle>" and "c = c\<^sub>1;;c\<^sub>2" and "c' = Skip"
hence "\<exists>s''. \<langle>c\<^sub>1,s\<rangle> \<rightarrow>* \<langle>Skip,s''\<rangle> \<and> \<langle>c\<^sub>2,s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
proof(induct arbitrary:c\<^sub>1 rule:converse_rtranclp_induct2)
case refl thus ?case by simp
next
case (step c s c'' s'')
note IH = `\<And>c\<^sub>1. \<lbrakk>c'' = c\<^sub>1;;c\<^sub>2; c' = Skip\<rbrakk>
\<Longrightarrow> \<exists>sx. \<langle>c\<^sub>1,s''\<rangle> \<rightarrow>* \<langle>Skip,sx\<rangle> \<and> \<langle>c\<^sub>2,sx\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>`
from step
have "\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c'',s''\<rangle>" by simp
hence "(c\<^sub>1 = Skip \<and> c'' = c\<^sub>2 \<and> s = s'') \<or>
(\<exists>c\<^sub>1'. \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle> \<and> c'' = c\<^sub>1';;c\<^sub>2)"
by(auto elim:red.cases)
thus ?case
proof
assume "c\<^sub>1 = Skip \<and> c'' = c\<^sub>2 \<and> s = s''"
with `\<langle>c'',s''\<rangle> \<rightarrow>* \<langle>c',s'\<rangle>` `c' = Skip`
show ?thesis by auto
next
assume "\<exists>c\<^sub>1'. \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle> \<and> c'' = c\<^sub>1';;c\<^sub>2"
then obtain c\<^sub>1' where "\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>" and "c'' = c\<^sub>1';;c\<^sub>2" by blast
from IH[OF `c'' = c\<^sub>1';;c\<^sub>2` `c' = Skip`]
obtain sx where "\<langle>c\<^sub>1',s''\<rangle> \<rightarrow>* \<langle>Skip,sx\<rangle>" and "\<langle>c\<^sub>2,sx\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
by blast
from `\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>` `\<langle>c\<^sub>1',s''\<rangle> \<rightarrow>* \<langle>Skip,sx\<rangle>`
have "\<langle>c\<^sub>1,s\<rangle> \<rightarrow>* \<langle>Skip,sx\<rangle>" by(auto intro:converse_rtranclp_into_rtranclp)
with `\<langle>c\<^sub>2,sx\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>` show ?thesis by auto
qed
qed }
with `\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>` show ?thesis by simp
qed
with that show ?thesis by blast
qed
lemma Cond_True_or_False:
"\<langle>if (b) c\<^sub>1 else c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some true \<or> \<lbrakk>b\<rbrakk> s = Some false"
by(induct c=="if (b) c\<^sub>1 else c\<^sub>2" s rule:converse_rtranclp_induct2)(auto elim:red.cases)
lemma CondTrue_reds:
"\<langle>if (b) c\<^sub>1 else c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some true \<Longrightarrow> \<langle>c\<^sub>1,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
by(induct c=="if (b) c\<^sub>1 else c\<^sub>2" s rule:converse_rtranclp_induct2)(auto elim:red.cases)
lemma CondFalse_reds:
"\<langle>if (b) c\<^sub>1 else c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> \<langle>c\<^sub>2,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
by(induct c=="if (b) c\<^sub>1 else c\<^sub>2" s rule:converse_rtranclp_induct2)(auto elim:red.cases)
lemma WhileFalse_reds:
"\<langle>while (b) cx,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> s = s'"
proof(induct "while (b) cx" s rule:converse_rtranclp_induct2)
case step thus ?case by(auto elim:red.cases dest: Skip_reds)
qed
lemma WhileTrue_reds:
"\<langle>while (b) cx,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some true
\<Longrightarrow> \<exists>sx. \<langle>cx,s\<rangle> \<rightarrow>* \<langle>Skip,sx\<rangle> \<and> \<langle>while (b) cx,sx\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>"
proof(induct "while (b) cx" s rule:converse_rtranclp_induct2)
case (step s c'' s'')
hence "c'' = cx;;while (b) cx \<and> s'' = s" by(auto elim:red.cases)
with `\<langle>c'',s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>` show ?case by(auto dest:Seq_reds)
qed
lemma While_True_or_False:
"\<langle>while (b) com,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle> \<Longrightarrow> \<lbrakk>b\<rbrakk> s = Some true \<or> \<lbrakk>b\<rbrakk> s = Some false"
by(induct c=="while (b) com" s rule:converse_rtranclp_induct2)(auto elim:red.cases)
inductive red_n :: "com \<Rightarrow> state \<Rightarrow> nat \<Rightarrow> com \<Rightarrow> state \<Rightarrow> bool"
("((1\<langle>_,/_\<rangle>) \<rightarrow>\<^bsup>_\<^esup> (1\<langle>_,/_\<rangle>))" [0,0,0,0,0] 81)
where red_n_Base: "\<langle>c,s\<rangle> \<rightarrow>\<^bsup>0\<^esup> \<langle>c,s\<rangle>"
| red_n_Rec: "\<lbrakk>\<langle>c,s\<rangle> \<rightarrow> \<langle>c'',s''\<rangle>; \<langle>c'',s''\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>c',s'\<rangle>\<rbrakk> \<Longrightarrow> \<langle>c,s\<rangle> \<rightarrow>\<^bsup>Suc n\<^esup> \<langle>c',s'\<rangle>"
lemma Seq_red_nE: assumes "\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>"
obtains i j s'' where "\<langle>c\<^sub>1,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle>" and "\<langle>c\<^sub>2,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>"
and "n = i + j + 1"
proof -
from `\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>`
have "\<exists>i j s''. \<langle>c\<^sub>1,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle> \<and> \<langle>c\<^sub>2,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle> \<and> n = i + j + 1"
proof(induct "c\<^sub>1;;c\<^sub>2" s n "Skip" s' arbitrary:c\<^sub>1 rule:red_n.induct)
case (red_n_Rec s c'' s'' n s')
note IH = `\<And>c\<^sub>1. c'' = c\<^sub>1;;c\<^sub>2
\<Longrightarrow> \<exists>i j sx. \<langle>c\<^sub>1,s''\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,sx\<rangle> \<and> \<langle>c\<^sub>2,sx\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle> \<and> n = i + j + 1`
from `\<langle>c\<^sub>1;;c\<^sub>2,s\<rangle> \<rightarrow> \<langle>c'',s''\<rangle>`
have "(c\<^sub>1 = Skip \<and> c'' = c\<^sub>2 \<and> s = s'') \<or>
(\<exists>c\<^sub>1'. c'' = c\<^sub>1';;c\<^sub>2 \<and> \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>)"
by(induct "c\<^sub>1;;c\<^sub>2" _ _ _ rule:red_induct) auto
thus ?case
proof
assume "c\<^sub>1 = Skip \<and> c'' = c\<^sub>2 \<and> s = s''"
hence "c\<^sub>1 = Skip" and "c'' = c\<^sub>2" and "s = s''" by simp_all
from `c\<^sub>1 = Skip` have "\<langle>c\<^sub>1,s\<rangle> \<rightarrow>\<^bsup>0\<^esup> \<langle>Skip,s\<rangle>" by(fastforce intro:red_n_Base)
with `\<langle>c'',s''\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>` `c'' = c\<^sub>2` `s = s''`
show ?thesis by(rule_tac x="0" in exI) auto
next
assume "\<exists>c\<^sub>1'. c'' = c\<^sub>1';;c\<^sub>2 \<and> \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>"
then obtain c\<^sub>1' where "c'' = c\<^sub>1';;c\<^sub>2" and "\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>" by blast
from IH[OF `c'' = c\<^sub>1';;c\<^sub>2`] obtain i j sx
where "\<langle>c\<^sub>1',s''\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,sx\<rangle>" and "\<langle>c\<^sub>2,sx\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>"
and "n = i + j + 1" by blast
from `\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s''\<rangle>` `\<langle>c\<^sub>1',s''\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,sx\<rangle>`
have "\<langle>c\<^sub>1,s\<rangle> \<rightarrow>\<^bsup>Suc i\<^esup> \<langle>Skip,sx\<rangle>" by(rule red_n.red_n_Rec)
with `\<langle>c\<^sub>2,sx\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>` `n = i + j + 1` show ?thesis
by(rule_tac x="Suc i" in exI) auto
qed
qed
with that show ?thesis by blast
qed
lemma while_red_nE:
"\<langle>while (b) cx,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>
\<Longrightarrow> (\<lbrakk>b\<rbrakk> s = Some false \<and> s = s' \<and> n = 1) \<or>
(\<exists>i j s''. \<lbrakk>b\<rbrakk> s = Some true \<and> \<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle> \<and>
\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle> \<and> n = i + j + 2)"
proof(induct "while (b) cx" s n "Skip" s' rule:red_n.induct)
case (red_n_Rec s c'' s'' n s')
from `\<langle>while (b) cx,s\<rangle> \<rightarrow> \<langle>c'',s''\<rangle>`
have "(\<lbrakk>b\<rbrakk> s = Some false \<and> c'' = Skip \<and> s'' = s) \<or>
(\<lbrakk>b\<rbrakk> s = Some true \<and> c'' = cx;;while (b) cx \<and> s'' = s)"
by(induct "while (b) cx" _ _ _ rule:red_induct) auto
thus ?case
proof
assume "\<lbrakk>b\<rbrakk> s = Some false \<and> c'' = Skip \<and> s'' = s"
hence "\<lbrakk>b\<rbrakk> s = Some false" and "c'' = Skip" and "s'' = s" by simp_all
with `\<langle>c'',s''\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>` have "s = s'" and "n = 0"
by(induct _ _ Skip _ rule:red_n.induct,auto elim:red.cases)
with `\<lbrakk>b\<rbrakk> s = Some false` show ?thesis by fastforce
next
assume "\<lbrakk>b\<rbrakk> s = Some true \<and> c'' = cx;;while (b) cx \<and> s'' = s"
hence "\<lbrakk>b\<rbrakk> s = Some true" and "c'' = cx;;while (b) cx"
and "s'' = s" by simp_all
with `\<langle>c'',s''\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>`
obtain i j sx where "\<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,sx\<rangle>" and "\<langle>while (b) cx,sx\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>"
and "n = i + j + 1" by(fastforce elim:Seq_red_nE)
with `\<lbrakk>b\<rbrakk> s = Some true` show ?thesis by fastforce
qed
qed
lemma while_red_n_induct [consumes 1, case_names false true]:
assumes major: "\<langle>while (b) cx,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>"
and IHfalse:"\<And>s. \<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> P s s"
and IHtrue:"\<And>s i j s''. \<lbrakk> \<lbrakk>b\<rbrakk> s = Some true; \<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle>;
\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>; P s'' s'\<rbrakk> \<Longrightarrow> P s s'"
shows "P s s'"
using major
proof(induct n arbitrary:s rule:nat_less_induct)
fix n s
assume IHall:"\<forall>m<n. \<forall>x. \<langle>while (b) cx,x\<rangle> \<rightarrow>\<^bsup>m\<^esup> \<langle>Skip,s'\<rangle> \<longrightarrow> P x s'"
and "\<langle>while (b) cx,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>"
from `\<langle>while (b) cx,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>Skip,s'\<rangle>`
have "(\<lbrakk>b\<rbrakk> s = Some false \<and> s = s' \<and> n = 1) \<or>
(\<exists>i j s''. \<lbrakk>b\<rbrakk> s = Some true \<and> \<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle> \<and>
\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle> \<and> n = i + j + 2)"
by(rule while_red_nE)
thus "P s s'"
proof
assume "\<lbrakk>b\<rbrakk> s = Some false \<and> s = s' \<and> n = 1"
hence "\<lbrakk>b\<rbrakk> s = Some false" and "s = s'" by auto
from IHfalse[OF `\<lbrakk>b\<rbrakk> s = Some false`] have "P s s" .
with `s = s'` show ?thesis by simp
next
assume "\<exists>i j s''. \<lbrakk>b\<rbrakk> s = Some true \<and> \<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle> \<and>
\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle> \<and> n = i + j + 2"
then obtain i j s'' where "\<lbrakk>b\<rbrakk> s = Some true"
and "\<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle>" and "\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>"
and "n = i + j + 2" by blast
with IHall have "P s'' s'"
apply(erule_tac x="j" in allE) apply clarsimp done
from IHtrue[OF `\<lbrakk>b\<rbrakk> s = Some true` `\<langle>cx,s\<rangle> \<rightarrow>\<^bsup>i\<^esup> \<langle>Skip,s''\<rangle>`
`\<langle>while (b) cx,s''\<rangle> \<rightarrow>\<^bsup>j\<^esup> \<langle>Skip,s'\<rangle>` this] show ?thesis .
qed
qed
lemma reds_to_red_n:"\<langle>c,s\<rangle> \<rightarrow>* \<langle>c',s'\<rangle> \<Longrightarrow> \<exists>n. \<langle>c,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>c',s'\<rangle>"
by(induct rule:converse_rtranclp_induct2,auto intro:red_n.intros)
lemma red_n_to_reds:"\<langle>c,s\<rangle> \<rightarrow>\<^bsup>n\<^esup> \<langle>c',s'\<rangle> \<Longrightarrow> \<langle>c,s\<rangle> \<rightarrow>* \<langle>c',s'\<rangle>"
by(induct rule:red_n.induct,auto intro:converse_rtranclp_into_rtranclp)
lemma while_reds_induct[consumes 1, case_names false true]:
"\<lbrakk>\<langle>while (b) cx,s\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>; \<And>s. \<lbrakk>b\<rbrakk> s = Some false \<Longrightarrow> P s s;
\<And>s s''. \<lbrakk> \<lbrakk>b\<rbrakk> s = Some true; \<langle>cx,s\<rangle> \<rightarrow>* \<langle>Skip,s''\<rangle>;
\<langle>while (b) cx,s''\<rangle> \<rightarrow>* \<langle>Skip,s'\<rangle>; P s'' s'\<rbrakk> \<Longrightarrow> P s s'\<rbrakk>
\<Longrightarrow> P s s'"
apply(drule reds_to_red_n,clarsimp)
apply(erule while_red_n_induct,clarsimp)
by(auto dest:red_n_to_reds)
lemma red_det:
"\<lbrakk>\<langle>c,s\<rangle> \<rightarrow> \<langle>c\<^sub>1,s\<^sub>1\<rangle>; \<langle>c,s\<rangle> \<rightarrow> \<langle>c\<^sub>2,s\<^sub>2\<rangle>\<rbrakk> \<Longrightarrow> c\<^sub>1 = c\<^sub>2 \<and> s\<^sub>1 = s\<^sub>2"
proof(induct arbitrary:c\<^sub>2 rule:red_induct)
case (SeqRed c\<^sub>1 s c\<^sub>1' s' c\<^sub>2')
note IH = `\<And>c\<^sub>2. \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>2,s\<^sub>2\<rangle> \<Longrightarrow> c\<^sub>1' = c\<^sub>2 \<and> s' = s\<^sub>2`
from `\<langle>c\<^sub>1;;c\<^sub>2',s\<rangle> \<rightarrow> \<langle>c\<^sub>2,s\<^sub>2\<rangle>` have "c\<^sub>1 = Skip \<or> (\<exists>cx. c\<^sub>2 = cx;;c\<^sub>2' \<and> \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>cx,s\<^sub>2\<rangle>)"
by(fastforce elim:red.cases)
thus ?case
proof
assume "c\<^sub>1 = Skip"
with `\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>c\<^sub>1',s'\<rangle>` have False by(fastforce elim:red.cases)
thus ?thesis by simp
next
assume "\<exists>cx. c\<^sub>2 = cx;;c\<^sub>2' \<and> \<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>cx,s\<^sub>2\<rangle>"
then obtain cx where "c\<^sub>2 = cx;;c\<^sub>2'" and "\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>cx,s\<^sub>2\<rangle>" by blast
from IH[OF `\<langle>c\<^sub>1,s\<rangle> \<rightarrow> \<langle>cx,s\<^sub>2\<rangle>`] have "c\<^sub>1' = cx \<and> s' = s\<^sub>2" .
with `c\<^sub>2 = cx;;c\<^sub>2'` show ?thesis by simp
qed
qed (fastforce elim:red.cases)+
theorem reds_det:
"\<lbrakk>\<langle>c,s\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>1\<rangle>; \<langle>c,s\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>2\<rangle>\<rbrakk> \<Longrightarrow> s\<^sub>1 = s\<^sub>2"
proof(induct rule:converse_rtranclp_induct2)
case refl
from `\<langle>Skip,s\<^sub>1\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>2\<rangle>` show ?case
by -(erule converse_rtranclpE,auto elim:red.cases)
next
case (step c'' s'' c' s')
note IH = `\<langle>c',s'\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>2\<rangle> \<Longrightarrow> s\<^sub>1 = s\<^sub>2`
from step have "\<langle>c'',s''\<rangle> \<rightarrow> \<langle>c',s'\<rangle>"
by simp
from `\<langle>c'',s''\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>2\<rangle>` this have "\<langle>c',s'\<rangle> \<rightarrow>* \<langle>Skip,s\<^sub>2\<rangle>"
by -(erule converse_rtranclpE,auto elim:red.cases dest:red_det)
from IH[OF this] show ?thesis .
qed
end
|
{"author": "Josh-Tilles", "repo": "AFP", "sha": "f4bf1d502bde2a3469d482b62c531f1c3af3e881", "save_path": "github-repos/isabelle/Josh-Tilles-AFP", "path": "github-repos/isabelle/Josh-Tilles-AFP/AFP-f4bf1d502bde2a3469d482b62c531f1c3af3e881/thys/VolpanoSmith/Semantics.thy"}
|
# !/usr/bin/env python
# -*- coding:utf-8 -*-
import argparse
import cv2
import numpy as np
def color_encode(color):
if color == 'red':
return (0,0,255)
elif color == 'blue':
return (255,0,0)
elif color == 'green':
return (0,255,0)
elif color == 'yellow':
return (0,255,255)
elif color == 'black':
return (0,0,0)
else:
return (255,255,255)
def main():
parser = argparse.ArgumentParser(epilog="example to use: python3 -picture_path picture_path.jpg -to_color red")
parser.add_argument('-picture_path',required=True, help='Path to change backgroud file')
parser.add_argument('-to_color', choices=['white', 'blue','red','black','yellow','green'], default='white')
parser.add_argument('-save_path', default='change_bg_color.png')
parser.add_argument('-erode_num',type=int, default=2, help='腐蚀迭代次数 默认值 2')
parser.add_argument('-dilate_num',type=int, default=3, help='膨胀迭代次数 默认值 3')
opt = parser.parse_args()
if opt.picture_path == None:
parser.print_help()
exit(1)
to_color = color_encode(opt.to_color)
# step1:读取照片
img = cv2.imread(opt.picture_path)
# step1.2:缩放图片()
img = cv2.resize(img, None, fx=1.5, fy=1.5)
rows, cols, channels = img.shape
# 展示图片
#cv2.imshow("original...", img)
# step2.1 图片转换为灰度图并显示
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# :图片的二值化处理
# 将在两个阈值内的像素值设置为白色(255),
# 而不在阈值区间内的像素值设置为黑色(0)
lower_red = np.array([0, 125, 125])
upper_red = np.array([255, 255, 255])
mask = cv2.inRange(hsv, lower_red, upper_red)
# step2.3:腐蚀膨胀 若是腐蚀膨胀后仍有白色噪点,可以增加iterations的值
erode = cv2.erode(mask, None, iterations=opt.erode_num)
# cv2.imshow('erode', erode)
dilate = cv2.dilate(erode, None, iterations=opt.dilate_num)
# step3遍历每个像素点,进行颜色的替换
for i in range(rows):
for j in range(cols):
if dilate[i, j] == 255: # 像素点255表示白色,180为灰度
img[i, j] = to_color # 此处替换颜色,为BGR通道,不是RGB通道
# step4 保存图片
cv2.imwrite(opt.save_path, img)
#res = cv2.imread(opt.save_path)
#cv2.imshow('result...', res)
# 窗口等待的命令,0表示无限等待
#cv2.waitKey(0)
if __name__ == '__main__':
main()
|
{"hexsha": "07a623233d7a564c021bf57899ac2574810de382", "size": 2253, "ext": "py", "lang": "Python", "max_stars_repo_path": "others/change_bg_color.py", "max_stars_repo_name": "daishoui/ex", "max_stars_repo_head_hexsha": "fd75f6a907cabb6c60036136b6a182a7d025d4b3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "others/change_bg_color.py", "max_issues_repo_name": "daishoui/ex", "max_issues_repo_head_hexsha": "fd75f6a907cabb6c60036136b6a182a7d025d4b3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "others/change_bg_color.py", "max_forks_repo_name": "daishoui/ex", "max_forks_repo_head_hexsha": "fd75f6a907cabb6c60036136b6a182a7d025d4b3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.5189873418, "max_line_length": 115, "alphanum_fraction": 0.6222814026, "include": true, "reason": "import numpy", "num_tokens": 819}
|
import os
from operator import add
import numpy as np
import torch
from PIL import Image
from torchvision.datasets import CocoDetection
from transforms import ToImgaug, ImgaugToTensor
class CocoMask(CocoDetection):
def __init__(self, root, annFile, transform=None, target_transform=None, transforms=None, use_mask=True):
super(CocoMask, self).__init__(root, annFile, transforms, target_transform, transform)
self.transforms = transforms
self.use_mask = use_mask
# TODO: avoid memory leak, use numpy arrays and avoid using self.coco, which uses lists
# (https://github.com/pytorch/pytorch/issues/13246#issuecomment-617140519)
def __getitem__(self, index):
coco = self.coco
img_id = self.ids[index]
ann_ids = coco.getAnnIds(imgIds=img_id)
target = coco.loadAnns(ann_ids)
path = coco.loadImgs(img_id)[0]['file_name']
img = Image.open(os.path.join(self.root, path)).convert('RGB')
# From boxes [x, y, w, h] to [x1, y1, x2, y2]
new_target = {"image_id": np.array(img_id, dtype=np.int64),
"area": np.array([obj['area'] for obj in target], dtype=np.float32),
"iscrowd": np.array([obj['iscrowd'] for obj in target], dtype=np.int64),
"boxes": np.array([obj['bbox'][:2] + list(map(add, obj['bbox'][:2], obj['bbox'][2:]))
for obj in target], dtype=np.float32),
"labels": np.array([obj['category_id'] for obj in target], dtype=np.int64)}
if self.use_mask:
mask = [coco.annToMask(ann) for ann in target]
if len(mask) > 1:
mask = np.stack(tuple(mask), axis=0)
new_target["masks"] = torch.as_tensor(mask, dtype=torch.uint8)
if self.transforms is not None:
img, new_target = ToImgaug(img.convert('RGB'), new_target)
img, new_target['boxes'] = self.transforms(image=img,
bounding_boxes=new_target['boxes'])
img, new_target = ImgaugToTensor(img, new_target)
return img, new_target
|
{"hexsha": "88cb95bfbf43fff29cdd5e21e133c70fe7027323", "size": 2181, "ext": "py", "lang": "Python", "max_stars_repo_path": "datasets.py", "max_stars_repo_name": "danmalowany/trains-model-zoo", "max_stars_repo_head_hexsha": "2091100057afae9593b18ddcefd81b7d46724a96", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "datasets.py", "max_issues_repo_name": "danmalowany/trains-model-zoo", "max_issues_repo_head_hexsha": "2091100057afae9593b18ddcefd81b7d46724a96", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-08T21:53:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-08T21:53:42.000Z", "max_forks_repo_path": "datasets.py", "max_forks_repo_name": "danmalowany/trains-model-zoo", "max_forks_repo_head_hexsha": "2091100057afae9593b18ddcefd81b7d46724a96", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.62, "max_line_length": 109, "alphanum_fraction": 0.6024759285, "include": true, "reason": "import numpy", "num_tokens": 527}
|
% Time-Variable Input
In earlier versions of MODFLOW, most stress-boundary packages read input on a stress period-by-stress period basis, and those values were held constant during the stress period. In \programname{}, many stress values can be specified with a higher degree of time resolution (from time step to time step or from subtime step to subtime step) by using one of two time-variable approaches. Boundaries for which data are read as lists of cells can reference ``time series'' to implement the time variation. Boundaries for which data are read as 2-D arrays can reference ``time-array series'' to do so.
When \programname{} needs data from a time series or time-array series for a time interval representing a time step or subtime step, the series is queried to provide a time-averaged value or array of values for the requested time interval. For each series, the user specifies an interpolation method that determines how the value is assumed to behave between listed times. The interpolation method thus determines how the time averaging is performed. When a time-array series is used, interpolation is performed on an element-by-element basis to generate a 2-D array of interpolated values as needed.
The supported interpolation methods are STEPWISE, LINEAR, and LINEAREND. When the STEPWISE interpolation method is used, the value is assumed to remain constant at the value specified in one time-series record until the time listed in the subsequent record, when the value changes abruptly to the new value. In the LINEAR interpolation method, the value is assumed to change linearly between times listed in sequential records. LINEAREND is like LINEAR, except that instead of using the average value over a time step, the value at the end of a time step is used. Following sections document the structure of time-series and time-array-series files and their use.
% Time series
\subsection{Time Series}
Any package that reads data as a list of cells and associated time-dependent input values can obtain those values from time series. For example, flow rates for a well or stage for a river boundary can be extracted from time series. During a simulation, values used for time-varying stresses (or auxiliary values) are based on the values provided in the time series and are updated each time step (or each subtime step, as appropriate). Input to define and use time series is described in this section.
A time series consists of a chronologically ordered list of time-series records, where each record includes a discrete time and a corresponding value. The value can be used to provide any time-varying numeric input, including stresses and auxiliary variables. A time series can be referenced in input for one or multiple variables in a given package.
% Time-series files
\subsubsection{Time-Series Files}
Each time-series file is associated with exactly one package, and the name of a time-series file associated with a package is listed in the OPTIONS block for the package, preceded by the keywords ``TS6 FILEIN.'' Any number of time-series files can be associated with a given package; a TS6 entry is required for each time-series file. A time-series file can contain one or more time series. Time-series files are not listed in either the simulation Name File or the model Name File. A given time-series file cannot be associated with more than one package. By convention, the extension ``.ts'' is used in names of time-series files.
Each time-series file contains an ATTRIBUTES block followed by a TIMESERIES block containing a series of lines, where each line contains a time followed by values for one or more time series at the specified time. The ATTRIBUTES block is required to define the name for each time series and the interpolation method to be used when an operation requires interpolation between times listed in the time series.
The time-series name(s) and interpolation method(s) are specified in the ATTRIBUTES block. Scale factor(s) for multiplying values optionally can be provided in the ATTRIBUTES block. NAME, METHOD, METHODS, SFAC, and SFACS are keywords. For appearance when a time-series file includes multiple time series, NAMES can be used as a synonym for the NAME keyword.
The syntax of the ATTRIBUTES block for a time-series file containing a single time series is as follows:
% ATTRIBUTES block of TS6 file for a single time series
\begin{lstlisting}[style=blockdefinition]
BEGIN ATTRIBUTES
NAME time-series-name
METHOD interpolation-method
[ SFAC sfac ]
END ATTRIBUTES
\end{lstlisting}
When a time-series file contains multiple time series, the time-series names are listed in a NAME (or NAMES) entry, similar to the example above. If the time series are to have different interpolation methods, the METHODS keyword is used in place of the METHOD keyword, and an interpolation method corresponding to each name is listed. If the time series are to have different scale factors, the SFACS keyword is used in place of the SFAC keyword.
The syntax of the ATTRIBUTES block for a time-series file containing multiple time series is as follows:
% ATTRIBUTES block of TS6 file for multiple time series
\begin{lstlisting}[style=blockdefinition]
BEGIN ATTRIBUTES
NAMES time-series-name-1 [ time-series-name-2 ... time-series-name-n ]
METHODS interpolation-method-1 [ interpolation-method-2 ... ]
[ SFACS sfac-1 [ sfac-2 ... sfac-n ] ]
END ATTRIBUTES
\end{lstlisting}
In a case where a time-series file contains multiple time series and a single interpolation method applies to all time series in the file, the METHOD keyword can be used, and a single interpolation method is read. Similary, if a single scale factor applies to all time series in the file, the SFAC keyword can be used, and a single scale factor is read.
The ATTRIBUTES block is followed by a TIMESERIES block of the form:
\begin{lstlisting}[style=blockdefinition]
BEGIN TIMESERIES
time-series record
time-series record
...
time-series record
END TIMESERIES
\end{lstlisting}
\noindent where each time-series record is of the form:\\
\begin{lstlisting}[style=blockdefinition]
tsr-time tsr-value-1 [ tsr-value-2 tsr-value-3 ... ]
\end{lstlisting}
In situations where an individual time series in a file containing multiple time series does not include values for all specified times, a ``no-data'' value (3.0E30) can be used as a placeholder. When the ``no-data'' value is read for a time series, that time series will not include a time-series record for the corresponding time.
% Explanation of Variables (Time-Series File)
\subsubsection{Explanation of Variables}
% time-series-name description
\begin{description}
\item \texttt{time-series-name}---Name by which a package references a particular time series. The name must be unique among all time series used in a package.
\end{description}
% interpolation-method description
\begin{description}
\item \texttt{interpolation-method}---Interpolation method, which is either STEPWISE, LINEAR, or LINEAREND.
\end{description}
% sfac description
\begin{description}
\item \texttt{sfac}---Scale factor, which will multiply all \texttt{tsr-value} values in the time series. SFAC and SFACS are optional attributes; if omitted, \texttt{sfac} = 1.0.
\end{description}
% tsr-time description
\begin{description}
\item \texttt{tsr-time}---A numeric time relative to the start of the simulation, in the time unit used in the simulation. Times must be strictly increasing.
\end{description}
% tsr-value description
\begin{description}
\item \texttt{tsr-value}---A numeric data value corresponding to tsr-time. The value 3.0E30 is treated as a ``no-data'' value and can be used wherever a time series in a file containing multiple time series does not have a value corresponding to the time specified by \texttt{tsr-time}.
\end{description}
%\vspace{5mm}
% Using time series in a package
\subsubsection{Using Time Series in a Package}
When one or more time series are to define numeric input for a package, the name(s) of time-series files need to be defined in an OPTIONS block at the top of the package input file. The keyword TS6 followed by the keyword FILEIN are used to identify the name of each time-series file. Each time-series file can contain one or more time series, and each OPTIONS block can contain zero or more TS6 entries. The syntax for a TS6 entry in an OPTIONS block is:
% OPTIONS block: syntax for TIMESERIESFILE
\begin{lstlisting}[style=blockdefinition]
BEGIN OPTIONS
TS6 FILEIN time-series-file-name
END OPTIONS
\end{lstlisting}
% Explanation of Variables Read from a Package Input File
\noindent \textbf{Explanation of Variables Read from a Package Input File:}
% time-series-name description
\begin{description}
\item \texttt{TS6}---Keyword to specify that record corresponds to a time-series file.
\item \texttt{FILEIN}---Keyword to specify that an input filename is expected next.
\item \texttt{time-series-file-name}---Name of a time-series file in which time series used in the package are defined.
\end{description}
Each time series has a name. To specify that time-dependent values for one or more stress periods is to be extracted from a time series, the time-series name is listed in the position where a numeric value normally would be provided.
\vspace{5 mm}
% Example use of time series
\noindent \textbf{Example use of time series to define package input}
The following example illustrates the use of three time series in input for the Well Package in a model with a structured grid. For an unstructured grid, the layer, row, and column indices for each observation would be replaced by a node number.
\vspace{5 mm}
%Contents of file well_pump_rates.ts:
Contents of file ``well\_pump\_rates.ts'':
\begin{lstlisting}[style=inputfile]
BEGIN ATTRIBUTES
NAMES well-A-series well-B-series well-C-series
METHODS stepwise linear stepwise
END ATTRIBUTES
BEGIN TIMESERIES
# time well-A-series well-B-series well-C-series
0.0 0.0 0.0 0.0
1.0 -500.0 0.0 -400.0
2.0 -500.0 -1000.0 -500.0
5.0 -500.0 -1200.0 -200.0
8.0 -500.0 -1100.0 0.0
END TIMESERIES
\end{lstlisting}
Contents of the Well Package input file:
\begin{lstlisting}[style=inputfile]
BEGIN OPTIONS
TS6 FILEIN well_pump_rates.ts
END OPTIONS
BEGIN DIMENSIONS
MAXBOUND 4
END DIMENSIONS
BEGIN PERIOD 2
#layer row col Q (or time series)
9 192 44 well-A-series
10 43 17 well-B-series
11 12 17 well-C-series
END PERIOD
BEGIN PERIOD 4
#layer row col Q (or time series)
9 192 44 well-A-series
10 43 17 well-B-series
11 12 17 well-C-series
2 27 36 -900.0
END PERIOD
BEGIN PERIOD 8
2 27 36 -900.0
END PERIOD
\end{lstlisting}
In the example above, the Well package would have zero wells active in stress period 1. Three wells whose discharge rates are controlled by time series well-A-series, well-B-series, and well-C-series would be active in stress periods 2 and 3. Stress periods 4 through 7 would include the three time-series-controlled wells plus a well with a constant discharge of 900 (L\textsuperscript{3}/T). In stress period 8, only the constant-discharge well would be active.
% Time-Array Series
\subsection{Time-Array Series}
Any package that reads data for a structured model in the form of 2-D arrays can obtain those array data from a time-array series. For example, recharge rates or maximum evapotranspiration rates can be extracted from time-array series. During a simulation, values used for time-varying stresses (or auxiliary values) are based on the values provided in the time-array series and are updated each time step (or each subtime step, as appropriate). Input to define and use time-array series is described in this section.
A time-array series consists of a chronologically ordered list of arrays, where each array is associated with a discrete time. The array data can be used to provide any time-varying, array-based numeric input.
% Time-Array-Series Files
\subsubsection{Time-Array-Series Files}
Each time-array-series file is associated with exactly one package, and the name of a time-array-series file associated with a package is listed in the OPTIONS block for the package, preceded by the keywords ``TAS6 FILEIN.'' Any number of time-array-series files can be associated with a given package; a TAS6 entry is required for each time-array-series file. Time-array-series files are not listed in either the simulation Name File or the model Name File. A given time-array-series file cannot be associated with more than one package.
One time-array-series file defines a single time-array series. A time-array-series file contains an ATTRIBUTES block followed by a series of TIME blocks, where each TIME block contains data to define an array corresponding to a discrete time. The READARRAY array reading utility is used to read the array. The ATTRIBUTES block is required to define the name for the time-array series and the interpolation method to be used when an operation requires interpolation between times listed in the time-array series. By convention, the extension ``.tas'' is used in names of time-array-series files.
The syntax of the ATTRIBUTES block for a time-array-series file is as follows:
% ATTRIBUTES block of Time-Array-Series file
\begin{lstlisting}[style=blockdefinition]
BEGIN ATTRIBUTES
NAME time-array-series-name
METHOD interpolation-method
[ SFAC sfac ]
END ATTRIBUTES
\end{lstlisting}
The ATTRIBUTES block is followed by any number of TIME blocks of the form:\\
\begin{lstlisting}[style=blockdefinition]
BEGIN TIME tas-time
tas-array
END TIME
\end{lstlisting}
% Explanation of Variables (Time-Array-Series File)
\subsubsection{Explanation of Variables}
% time-array-series-name description
\begin{description}
\item \texttt{time-array-series-name}---Name by which a package references a particular time-array series. The name must be unique among all time-array series used in a package.
\end{description}
% interpolation-method description
\begin{description}
\item \texttt{interpolation-method}---Interpolation method, which is either STEPWISE or LINEAR.
\end{description}
% tas-time description
\begin{description}
\item \texttt{sfac}---Scale factor, which will multiply all array values in time series. SFAC is an optional attribute; if omitted, SFAC = 1.0.
\end{description}
% tas-time description
\begin{description}
\item \texttt{tas-time}---A numeric time relative to the start of the simulation, in the time unit used in the simulation. Times must be strictly increasing.
\end{description}
% tas-array description
\begin{description}
\item \texttt{tas-array}---A 2-D array of numeric, floating-point values, or a constant value, readable by the READARRAY array-reading utility.
\end{description}
% Using Time-Array Series in a Package
\subsubsection{Using Time-Array Series in a Package}
When one or more time-array series are to define numeric input for a package, the name(s) of time-array-series file(s) need to be defined in an OPTIONS block at the top of the package input file. The keywords ``TAS6 FILEIN'' are used to identify the name of each time-array-series file. Each time-array-series file contains exactly one time-array series, and each OPTIONS block can contain zero or more TAS6 entries. The syntax for a TAS6 entry in an OPTIONS block is:
% OPTIONS block: syntax for TIMEARRAYSERIESFILE
\begin{lstlisting}[style=blockdefinition]
BEGIN OPTIONS
TAS6 FILEIN time-array-series-file-name
END OPTIONS
\end{lstlisting}
A time-array series is linked to an array in one or more stress period blocks used to define package input. To indicate that an array is to be controlled by a time-array series, the array property word is followed by the keyword TIMEARRAYSERIES and the time-array series name. When the TIMEARRAYSERIES keyword is found (and the array to be populated supports time-array series), the array reader is not invoked. Consequently, the array-control record and any associated input are omitted. The syntax to define the link is:
% Syntax for stress period block
\begin{lstlisting}[style=blockdefinition]
BEGIN PERIOD kper
property-name TIMEARRAYSERIES time-array-series-name
END PERIOD
\end{lstlisting}
% Explanation of Variables Read from a Package Input File
\noindent \textbf{Explanation of Variables Read from a Package Input File:}
% time-array-series-name description
\begin{description}
\item \texttt{TAS6}---Keyword to specify that record corresponds to a time-array-series file.
\item \texttt{FILEIN}---Keyword to specify that an input filename is expected next.
\item \texttt{time-array-series-file-name}---Name of a time-array-series file in which a time-array series used in the package is defined.
\end{description}
\begin{description}
\item \texttt{property-name}---Name of property represented by array to be controlled by a time-array series.
\end{description}
\begin{description}
\item \texttt{time-array-series-name}---Name of time-array series. The time-array series must be defined in one of the files listed in the OPTIONS block with the TAS6 FILEIN keywords.
\end{description}
\vspace{5 mm}
% Example use of time-array series
\noindent \textbf{Example use of time-array series to define package input}
The following example illustrates the use of a time-array series to control the Recharge property of the Recharge package in a model with a structured grid. In this example time-array series values are obtained from the time-array series ``RchArraySeries\_1'' defined in file ``rch\_time\_array\_series.tas.'' The RchMult array is an auxiliary-variable array that is identified by the AUXMULTNAME keyword to be a multiplier for the recharge array. Accordingly, the recharge array is defined each time step as the element-by-element product of values interpolated from the ``RchArraySeries\_1'' time-array series and values from the auxiliary-variable RchMult array.
\vspace{5 mm}
Contents of Recharge package input file:
\begin{lstlisting}[style=inputfile]
BEGIN OPTIONS
READASARRAYS
AUX RchMult
TAS6 FILEIN rch_time_array_series.tas
AUXMULTNAME RchMult
PRINT_INPUT
END OPTIONS
BEGIN PERIOD 1
IRCH
CONSTANT 1
RECHARGE TIMEARRAYSERIES RchArraySeries_1
RchMult
INTERNAL FACTOR 1.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 1.0 0.5 0.5 0.0 0.0 0.0 0.0 0.0
0.0 1.0 1.0 1.0 1.0 0.5 0.0 0.0 0.0 0.0
0.0 1.0 1.0 1.0 1.0 1.0 0.5 0.0 0.0 0.0
0.0 0.2 1.0 1.0 1.0 1.0 1.0 0.5 0.2 0.0
0.0 0.0 0.5 1.0 1.0 1.0 1.0 0.5 0.0 0.0
0.0 0.0 0.0 0.2 0.2 0.2 0.2 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
END PERIOD
\end{lstlisting}
Contents of file ``rch\_time\_array\_series.tas'':
\begin{lstlisting}[style=inputfile]
BEGIN ATTRIBUTES
NAME RchArraySeries_1
METHOD LINEAR
END ATTRIBUTES
BEGIN TIME 0.0
CONSTANT 0.0033
END TIME
BEGIN TIME 91.0
CONSTANT 0.0035
END TIME
BEGIN TIME 183.0
CONSTANT 0.0037
END TIME
BEGIN TIME 274.0
CONSTANT 0.0039
END TIME
BEGIN TIME 365.0
CONSTANT 0.0035
END TIME
\end{lstlisting}
|
{"hexsha": "f2aaa4c05e7b2439f7b8b00bae2465172d429a24", "size": 19456, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "doc/mf6io/gwf/tsi.tex", "max_stars_repo_name": "scharlton2/modflow6", "max_stars_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 102, "max_stars_repo_stars_event_min_datetime": "2017-12-19T09:56:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T01:47:28.000Z", "max_issues_repo_path": "doc/mf6io/gwf/tsi.tex", "max_issues_repo_name": "scharlton2/modflow6", "max_issues_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 331, "max_issues_repo_issues_event_min_datetime": "2018-01-10T21:22:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T05:57:00.000Z", "max_forks_repo_path": "doc/mf6io/gwf/tsi.tex", "max_forks_repo_name": "scharlton2/modflow6", "max_forks_repo_head_hexsha": "83ac72ee3b6f580aaffef6352cf15c1697d3ce66", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 87, "max_forks_repo_forks_event_min_datetime": "2017-12-13T21:40:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T05:31:40.000Z", "avg_line_length": 55.7478510029, "max_line_length": 665, "alphanum_fraction": 0.7650596217, "num_tokens": 4974}
|
import sys
import socket
import binascii
import networkx as nx
import matplotlib.pyplot as plt
from pcapng import FileScanner
from pcapng import blocks
def get_pcap_packet_blocks(filename):
packet_blocks = []
with open(filename, 'rb') as fp:
scanner = FileScanner(fp)
for block in scanner:
if isinstance(block, blocks.EnhancedPacket):
packet_blocks.append(block)
return packet_blocks
class EthernetFrame():
def __init__(self, packet_bytes):
self._parse_packet(packet_bytes)
def _parse_packet(self, packet_bytes):
self.dst = packet_bytes[0:6]
self.src = packet_bytes[6:12]
self.type = packet_bytes[12:14]
self.data = packet_bytes[14:]
def __str__(self):
return 'EthernetFrame:\nDestination: {}\nSource: {}\nType: {}\nData: {}'.format(self.dst, self.src, self.type, self.data)
def get_eth_frame(packet_block):
if not packet_block.interface.link_type == 1:
return None
packet_data = packet_block.packet_data
ethernet_frame = EthernetFrame(packet_data)
return ethernet_frame
class IPv4_Packet():
def __init__(self, data):
self._parse_packet(data)
def _parse_packet(self, data):
self.version = data[0] >> 4
# extract header length (number of 32-bit words in the header)
ihl = data[0] & int('00001111', 2)
header_size = ihl * 4 # so multiply by 4 to get the number of bytes
# get the total size of the packet (header + data)
total_size = int(binascii.hexlify(data[2:4]), 16)
# set the internal values (this also drops the padding from the internet frame)
self.header = data[0:header_size]
self.data = data[header_size:total_size]
self.protocol = data[9]
self.src_ip = data[12:16]
self.dst_ip = data[16:20]
def get_ipv4_packet(ethernet_frameethernet_frame):
# Check that the ethernet frame has tpye 0x0800 and is IPv4
if not ethernet_frame.type == b'\x08\x00':
return None
ipv4_packet = IPv4_Packet(ethernet_frame.data)
return ipv4_packet
if __name__ == '__main__':
FILENAME = sys.argv[1]
OUTPUT = sys.argv[2]
if FILENAME is None:
print('Pcapng file not found!')
exit(1)
if OUTPUT is None:
OUTPUT = 'output'
pbs = get_pcap_packet_blocks(FILENAME)
with open("output.txt",'w') as f: # write in text mode
for count, pb in enumerate(pbs):
ethernet_frame = get_eth_frame(pb)
ipv4_packet = get_ipv4_packet(ethernet_frame)
# only check for ipv4 packges
if not ethernet_frame.type == b'\x08\x00':
continue
f.write('{} {}\n'.format(socket.inet_ntoa(ipv4_packet.src_ip), socket.inet_ntoa(ipv4_packet.dst_ip)))
G = nx.read_edgelist('output.txt', create_using=nx.Graph())
nx.draw(G, with_labels=True)
fig = plt.gcf()
fig.set_size_inches(50, 15, forward=True)
plt.savefig("{}.svg".format(OUTPUT), dpi=1000)
|
{"hexsha": "8bed8c14d8a6636cd350221f7b321433568c4f52", "size": 3116, "ext": "py", "lang": "Python", "max_stars_repo_path": "simple-pcapng-visualizer.py", "max_stars_repo_name": "heyi1999/simple-pcapng-visualizer", "max_stars_repo_head_hexsha": "785102efd2408e7526c0aebecbe2da057b697bf9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "simple-pcapng-visualizer.py", "max_issues_repo_name": "heyi1999/simple-pcapng-visualizer", "max_issues_repo_head_hexsha": "785102efd2408e7526c0aebecbe2da057b697bf9", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "simple-pcapng-visualizer.py", "max_forks_repo_name": "heyi1999/simple-pcapng-visualizer", "max_forks_repo_head_hexsha": "785102efd2408e7526c0aebecbe2da057b697bf9", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5752212389, "max_line_length": 129, "alphanum_fraction": 0.636071887, "include": true, "reason": "import networkx", "num_tokens": 783}
|
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <boost/test/unit_test.hpp>
#pragma GCC diagnostic pop
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/resource_limits.hpp>
#include <eosio/testing/tester.hpp>
#include <fc/exception/exception.hpp>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
#include "eosio_system_tester.hpp"
BOOST_AUTO_TEST_SUITE(rem_account_price_tests)
BOOST_FIXTURE_TEST_CASE(rem_account_price_test, rem_system::eosio_system_tester) {
try {
cross_15_percent_threshold();
produce_blocks(10);
// everyone should be able to create account with given price
{
const int64_t account_price = 50'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser111),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// everyone should be able to create account with given price
{
const int64_t account_price = 10'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser222),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// everyone should be able to create account with given price
{
const int64_t account_price = 1'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser333),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// everyone should be able to create account with given price
{
const int64_t account_price = 1;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser335),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// ram_gift_bytes should be equal 0 in this tests
// everyone should be able to create account with given price
{
const int64_t account_price = 100'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser444),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// everyone should be able to create account with given price
{
const int64_t account_price = 1000'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser555),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
// everyone should be able to create account with given price
{
const int64_t account_price = 10000'0000;
push_action( config::system_account_name, N(setminstake), mvo()("min_account_stake", account_price) );
const auto min_account_stake = get_global_state()["min_account_stake"].as<int64_t>();
BOOST_REQUIRE_EQUAL(min_account_stake, account_price);
create_account_with_resources(
N(testuser511),
config::system_account_name,
false,
asset{ account_price }
);
produce_blocks(1);
}
} FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_SUITE_END()
|
{"hexsha": "3e9a9318229930f1204f021821da0e305dc1652d", "size": 5162, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "unittests/rem_account_price_test.cpp", "max_stars_repo_name": "Remmeauth/core", "max_stars_repo_head_hexsha": "578996ce408ca0adbe6a6b895177199017ee907b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 140.0, "max_stars_repo_stars_event_min_datetime": "2019-07-01T13:13:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-23T12:50:39.000Z", "max_issues_repo_path": "unittests/rem_account_price_test.cpp", "max_issues_repo_name": "Remmeauth/core", "max_issues_repo_head_hexsha": "578996ce408ca0adbe6a6b895177199017ee907b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 26.0, "max_issues_repo_issues_event_min_datetime": "2019-07-12T09:07:36.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-20T20:33:06.000Z", "max_forks_repo_path": "unittests/rem_account_price_test.cpp", "max_forks_repo_name": "Remmeauth/core", "max_forks_repo_head_hexsha": "578996ce408ca0adbe6a6b895177199017ee907b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7.0, "max_forks_repo_forks_event_min_datetime": "2019-08-30T08:29:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-30T15:35:10.000Z", "avg_line_length": 33.7385620915, "max_line_length": 114, "alphanum_fraction": 0.6251452925, "num_tokens": 1076}
|
modelMatrix = function(x,
interactions = FALSE, intercept = FALSE){
#' Create a sparse design matrix from data frame
#'
#' \code{modelMatrix} takes in a data.frame and encodes it as a sparse model.Matrix object.
#' Factors use treatment ("one-hot") encoding, creating indicator variables from categorical
#' and binary variables.
#' Note that names of categorical variables will change slightly
#' (n-1 unique values appended to name)
#'
#' @param x A data.frame with finite, non-missing elements.
#' @param interactions Logical; if \code{TRUE} then all interactions included.
#' @param intercept Logcal; if \code{TRUE} then include a leading column of 1's.
if(is.null(x))return(NULL) #Dealing w/ empty data
#if (sum(sapply(x, is.finite)) != 0){
# stop('Creating model matrix requires all input elements be finite')}
#Set R to use 1-hot encoding
options(contrasts = rep("contr.treatment", 2))
model_formula = as.formula( ~.) #All first order Effects
if (interactions){model_formula = as.formula( ~(.)^2)} #1st order and interactions
mat = model.matrix(model_formula, data = data.frame(x))
if (!intercept){
#Remove intercept column, making sure names are preserved
n_vec = colnames(mat)
mat = data.frame(mat[ ,-1])
colnames(mat) = n_vec[-1]
}
#Drop any empty levels
n_vec = colnames(mat)
nonempty_indices = apply(abs(mat),2, sum) != 0
mat = data.frame(mat[ ,nonempty_indices])
p = length(mat)
colnames(mat) = n_vec[nonempty_indices]
n_cols = length(colnames(mat))
#Export as Matrix
mat = Matrix(sapply(mat, as.numeric))
return( mat)
}
|
{"hexsha": "00a3e7e5ef29bfc4e15df8eeeb91e7ff4ba9e1e6", "size": 1639, "ext": "r", "lang": "R", "max_stars_repo_path": "R/modelMatrix.r", "max_stars_repo_name": "dhelkey/babymonitor", "max_stars_repo_head_hexsha": "591dbfa43678ee25be1ea0d9601da78735be0639", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "R/modelMatrix.r", "max_issues_repo_name": "dhelkey/babymonitor", "max_issues_repo_head_hexsha": "591dbfa43678ee25be1ea0d9601da78735be0639", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "R/modelMatrix.r", "max_forks_repo_name": "dhelkey/babymonitor", "max_forks_repo_head_hexsha": "591dbfa43678ee25be1ea0d9601da78735be0639", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.0238095238, "max_line_length": 94, "alphanum_fraction": 0.6870042709, "num_tokens": 429}
|
from constants import Directions
import numpy as np
import matplotlib.pyplot as plt
import time
def simple_run(pool, direction):
def forward(f_pool):
node_to_run = f_pool[0]
f_pool = f_pool[1:]
node_to_run.forward()
f_pool.extend(list(filter(lambda ol: ol.can_forward, node_to_run.get_output_layers())))
return f_pool
def backward(b_pool):
node_to_run = b_pool[0]
b_pool = b_pool[1:]
node_to_run.backward()
b_pool.extend(list(filter(lambda il: il.can_backward, node_to_run.get_input_layers())))
return b_pool
return forward(pool) if direction == Directions.forward else backward(pool)
class Session:
def __init__(self, ends, train_x, train_y, test_x, test_y, run_algo=simple_run):
self.ends = ends
self.starts = set()
list(map(lambda e: self.starts.update(e.get_starts()), ends))
self.pool = []
self.run_algo = run_algo
self.train_x, self.train_y, self.test_x, self.test_y = train_x, train_y, test_x, test_y
self.cur_pred = []
def get_pool(self):
return self.pool
def run_batch(self, batch_x, batch_y, need_backward=True):
self.pool = list(self.starts)
list(map(lambda il: il.set_cur_input(batch_x), self.starts))
list(map(lambda ol: ol.set_cur_y_true(batch_y), self.ends))
while self.pool:
self.pool = self.run_algo(self.pool, direction=Directions.forward)
self.cur_pred.extend(self.ends[0].get_cur_outputs())
if need_backward:
self.pool = self.ends
while self.pool:
self.pool = self.run_algo(self.pool, direction=Directions.backward)
def train_epoch(self, batch_size=1, need_backward=True):
perm = np.random.permutation(self.train_x.shape[0])
epoch_x = self.train_x[perm]
epoch_y = self.train_y[perm]
count = len(self.train_x)
start_time = time.time()
self.cur_pred = []
i = 0
while i < count:
# self.run_batch(self.train_x[perm[i:i+batch_size]], self.train_y[perm[i:i+batch_size]], need_backward)
self.run_batch(epoch_x[i:i + batch_size], epoch_y[i:i + batch_size], need_backward)
i += batch_size
# print(self.cur_pred)
time_spent = time.time() - start_time
# self.cur_pred = []
# self.run_batch(self.train_x, self.train_y, need_backward=False)
train_loss, _, train_accuracy = self.ends[0].loss_function(epoch_y, self.cur_pred, 0)
self.cur_pred = []
self.run_batch(self.test_x, self.test_y, need_backward=False)
test_loss, _, test_accuracy = self.ends[0].loss_function(self.test_y, self.cur_pred, 0)
# print(self.train_y, self.cur_pred)
return train_loss, train_accuracy, test_loss, test_accuracy, time_spent
def train(self, epochs, batch_size):
train_losses = []
train_accuracies = []
test_losses = []
test_accuracies = []
for i in range(epochs):
train_loss, train_accuracy, test_loss, test_accuracy, time_spent = self.train_epoch(batch_size=batch_size)
print('Epoch {}:\ttime spent: {}s\nTrain loss: {};\taccuracy: {};\nTest loss: {};\taccuracy: {}.'.format(
i + 1, '%.4f' % time_spent, train_loss, train_accuracy, test_loss, test_accuracy))
print()
train_losses.append(train_loss)
train_accuracies.append(train_accuracy)
test_losses.append(test_loss)
test_accuracies.append(test_accuracy)
train_loss, train_accuracy, test_loss, test_accuracy, time_spent = self.train_epoch(batch_size=batch_size,
need_backward=False)
print('Final evaluate:\ttime spent: {}s\nTrain loss: {};\taccuracy: {};\nTest loss: {};\taccuracy: {}.'.format(
'%.4f' % time_spent, train_loss, train_accuracy, test_loss, test_accuracy))
history = {
'train_losses': train_losses[1:] + [train_loss],
'train_accuracies': train_accuracies[1:] + [train_accuracy],
'test_losses': test_losses,
'test_accuracies': test_accuracies
}
return history
|
{"hexsha": "3ee64c083d495c404d372936a352e5fecd4ac9cb", "size": 4311, "ext": "py", "lang": "Python", "max_stars_repo_path": "session.py", "max_stars_repo_name": "WallFacer5/ArtifIdiot", "max_stars_repo_head_hexsha": "698aac564901f64138b1e6287ab1996792a8f2fa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "session.py", "max_issues_repo_name": "WallFacer5/ArtifIdiot", "max_issues_repo_head_hexsha": "698aac564901f64138b1e6287ab1996792a8f2fa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-02-22T07:58:39.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-24T09:20:37.000Z", "max_forks_repo_path": "session.py", "max_forks_repo_name": "WallFacer5/models", "max_forks_repo_head_hexsha": "698aac564901f64138b1e6287ab1996792a8f2fa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.9897959184, "max_line_length": 119, "alphanum_fraction": 0.6260728369, "include": true, "reason": "import numpy", "num_tokens": 1000}
|
```python
import numpy as np
from pycalphad import Model, Database, calculate, equilibrium
import pycalphad.variables as v
#dbf = Database('2016-08-10-AlGdMgand18RLPSO-for 3d plot.tdb')
dbf = Database('alfe_sei.TDB')
models = {key: Model(dbf, ['AL', 'FE', 'VA'], key) for key in dbf.phases.keys()}
```
```python
#Set compiler directives (cf. http://docs.cython.org/src/reference/compilation.html)
%load_ext cython
from Cython.Compiler.Options import _directive_defaults
_directive_defaults['linetrace'] = True
_directive_defaults['binding'] = True
```
The cython extension is already loaded. To reload it, use:
%reload_ext cython
```cython
%%cython -a -f --compile-args=-DCYTHON_TRACE=1
import pycalphad.variables as v
from pycalphad.core.utils import unpack_kwarg
from pycalphad.core.utils import unpack_condition, unpack_phases
from pycalphad import calculate, Model
from pycalphad.constraints import mole_fraction
from pycalphad.core.lower_convex_hull import lower_convex_hull
from pycalphad.core.sympydiff_utils import build_functions as compiled_build_functions
from pycalphad.core.constants import MIN_SITE_FRACTION
from pycalphad.core.eqsolver import _solve_eq_at_conditions
from sympy import Add, Symbol
import dask
from dask import delayed
import dask.multiprocessing, dask.async
from xarray import Dataset
import numpy as np
cimport numpy as np
from collections import namedtuple, OrderedDict
from datetime import datetime
from pycalphad.core.eqsolver import *
from pycalphad.core.eqsolver import _build_multiphase_gradient, \
_build_multiphase_system, _compute_constraints, _compute_phase_dof, remove_degenerate_phases
cimport cython
def _solve_eq_at_conditions(dbf, comps, properties, phase_records, callable_dict, conds_keys, verbose):
"""
Compute equilibrium for the given conditions.
This private function is meant to be called from a worker subprocess.
For that case, usually only a small slice of the master 'properties' is provided.
Since that slice will be copied, we also return the modified 'properties'.
Parameters
----------
dbf : Database
Thermodynamic database containing the relevant parameters.
comps : list
Names of components to consider in the calculation.
properties : Dataset
Will be modified! Thermodynamic properties and conditions.
phase_records : dict of PhaseRecord
Details on phase callables.
callable_dict : dict of callable
Objective functions for each phase.
conds_keys : list of str
List of conditions axes in dimension order.
verbose : bool
Print details.
Returns
-------
properties : Dataset
Modified with equilibrium values.
"""
cdef:
double indep_sum
int num_phases, num_vars, cur_iter, old_phase_length, new_phase_length, var_idx, sfidx, pfidx, m, n
np.ndarray[ndim=1, dtype=np.float64_t] gradient_term, p_y, l_constraints, step
np.ndarray[ndim=1, dtype=np.float64_t] site_fracs, candidate_site_fracs, l_multipliers, new_l_multipliers, candidate_phase_fracs, phase_fracs
np.ndarray[ndim=2, dtype=np.float64_t] l_hessian, ymat, zmat, qmat, rmat, constraint_jac
# Factored out via profiling
prop_MU_values = properties['MU'].values
prop_NP_values = properties['NP'].values
prop_Phase_values = properties['Phase'].values
prop_X_values = properties['X'].values
prop_Y_values = properties['Y'].values
prop_GM_values = properties['GM'].values
it = np.nditer(prop_GM_values, flags=['multi_index'])
#if verbose:
# print('INITIAL CONFIGURATION')
# print(properties.MU)
# print(properties.Phase)
# print(properties.NP)
# print(properties.X)
# print(properties.Y)
# print('---------------------')
while not it.finished:
# A lot of this code relies on cur_conds being ordered!
cur_conds = OrderedDict(zip(conds_keys,
[np.asarray(properties['GM'].coords[b][a], dtype=np.float)
for a, b in zip(it.multi_index, conds_keys)]))
if len(cur_conds) == 0:
cur_conds = properties['GM'].coords
# sum of independently specified components
indep_sum = np.sum([float(val) for i, val in cur_conds.items() if i.startswith('X_')])
if indep_sum > 1:
# Sum of independent component mole fractions greater than one
# Skip this condition set
# We silently allow this to make 2-D composition mapping easier
prop_MU_values[it.multi_index] = np.nan
prop_NP_values[it.multi_index + np.index_exp[:len(phases)]] = np.nan
prop_Phase_values[it.multi_index + np.index_exp[:len(phases)]] = ''
prop_X_values[it.multi_index + np.index_exp[:len(phases)]] = np.nan
prop_Y_values[it.multi_index] = np.nan
prop_GM_values[it.multi_index] = np.nan
it.iternext()
continue
dependent_comp = set(comps) - set([i[2:] for i in cur_conds.keys() if i.startswith('X_')]) - {'VA'}
if len(dependent_comp) == 1:
dependent_comp = list(dependent_comp)[0]
else:
raise ValueError('Number of dependent components different from one')
# chem_pots = OrderedDict(zip(properties.coords['component'].values, properties['MU'].values[it.multi_index]))
# Used to cache generated mole fraction functions
mole_fractions = {}
for cur_iter in range(MAX_SOLVE_ITERATIONS):
# print('CUR_ITER:', cur_iter)
phases = list(prop_Phase_values[it.multi_index])
if '' in phases:
old_phase_length = phases.index('')
else:
old_phase_length = -1
remove_degenerate_phases(prop_Phase_values[it.multi_index], prop_X_values[it.multi_index],
prop_Y_values[it.multi_index], prop_NP_values[it.multi_index])
phases = list(prop_Phase_values[it.multi_index])
if '' in phases:
new_phase_length = phases.index('')
else:
new_phase_length = -1
# Are there removed phases?
if '' in phases:
num_phases = phases.index('')
else:
num_phases = len(phases)
if num_phases == 0:
raise ValueError('Zero phases are left in the system')
zero_dof = np.all(
(prop_Y_values[it.multi_index] == 1.) | np.isnan(prop_Y_values[it.multi_index]))
if (num_phases == 1) and zero_dof:
# Single phase with zero internal degrees of freedom, can't do any refinement
# TODO: In the future we may be able to refine other degrees of freedom like temperature
# Chemical potentials have no meaning for this case
prop_MU_values[it.multi_index] = np.nan
break
phases = prop_Phase_values[it.multi_index + np.index_exp[:num_phases]]
# num_sitefrac_bals = sum([len(dbf.phases[i].sublattices) for i in phases])
# num_mass_bals = len([i for i in cur_conds.keys() if i.startswith('X_')]) + 1
phase_fracs = prop_NP_values[it.multi_index + np.index_exp[:len(phases)]]
phase_dof = [len(set(phase_records[name].variables) - {v.T, v.P}) for name in phases]
# Flatten site fractions array and remove nan padding
site_fracs = prop_Y_values[it.multi_index].ravel()
# That *should* give us the internal dof
# This may break if non-padding nan's slipped in from elsewhere...
site_fracs = site_fracs[~np.isnan(site_fracs)]
site_fracs[site_fracs < MIN_SITE_FRACTION] = MIN_SITE_FRACTION
if len(site_fracs) == 0:
print(properties)
raise ValueError('Site fractions are invalid')
phase_fracs[phase_fracs < MIN_SITE_FRACTION] = MIN_SITE_FRACTION
var_idx = 0
for name in phases:
for idx in range(len(dbf.phases[name].sublattices)):
active_in_subl = set(dbf.phases[name].constituents[idx]).intersection(comps)
for ais in range(len(active_in_subl)):
site_fracs[var_idx + ais] = site_fracs[var_idx + ais] / sum(site_fracs[var_idx:var_idx + len(active_in_subl)])
var_idx += len(active_in_subl)
l_constraints, constraint_jac, constraint_hess = \
_compute_constraints(dbf, comps, phases, cur_conds, site_fracs, phase_fracs, phase_records, mole_fractions=mole_fractions)
# Reset Lagrange multipliers if active set of phases change
if cur_iter == 0 or (old_phase_length != new_phase_length) or np.any(np.isnan(l_multipliers)):
l_multipliers = np.zeros(l_constraints.shape[0])
qmat, rmat = np.linalg.qr(constraint_jac.T, mode='complete')
m = rmat.shape[1]
n = qmat.shape[0]
# Construct orthonormal basis for the constraints
ymat = qmat[:, :m]
zmat = qmat[:, m:]
# Equation 18.14a in Nocedal and Wright
p_y = np.linalg.solve(-np.dot(constraint_jac, ymat), l_constraints)
num_vars = len(site_fracs) + len(phases)
l_hessian, gradient_term = _build_multiphase_system(dbf, comps, phases, cur_conds, site_fracs, phase_fracs,
l_constraints, constraint_jac, constraint_hess,
l_multipliers, callable_dict, phase_records)
if np.any(np.isnan(l_hessian)):
print('Invalid l_hessian')
l_hessian[:,:] = np.eye(l_hessian.shape[0])
if np.any(np.isnan(gradient_term)):
raise ValueError('Invalid gradient_term')
# Equation 18.18 in Nocedal and Wright
if m != n:
if np.any(np.isnan(zmat)):
raise ValueError('Invalid zmat')
try:
p_z = np.linalg.solve(np.dot(np.dot(zmat.T, l_hessian), zmat),
-np.dot(np.dot(np.dot(zmat.T, l_hessian), ymat), p_y) - np.dot(zmat.T, gradient_term))
except np.linalg.LinAlgError:
p_z = np.zeros(zmat.shape[1], dtype=np.float)
step = np.dot(ymat, p_y) + np.dot(zmat, p_z)
else:
step = np.dot(ymat, p_y)
old_energy = copy.deepcopy(prop_GM_values[it.multi_index])
old_chem_pots = copy.deepcopy(prop_MU_values[it.multi_index])
candidate_site_fracs = np.empty_like(site_fracs)
candidate_phase_fracs = np.empty_like(phase_fracs)
for sfidx in range(candidate_site_fracs.shape[0]):
candidate_site_fracs[sfidx] = min(max(site_fracs[sfidx] + step[sfidx], MIN_SITE_FRACTION), 1)
for pfidx in range(candidate_phase_fracs.shape[0]):
candidate_phase_fracs[pfidx] = min(max(phase_fracs[pfidx] + step[candidate_site_fracs.shape[0] + pfidx], 0), 1)
candidate_l_constraints, candidate_constraint_jac, candidate_constraint_hess = \
_compute_constraints(dbf, comps, phases, cur_conds,
candidate_site_fracs, candidate_phase_fracs, phase_records, mole_fractions=mole_fractions)
candidate_energy, candidate_gradient_term = \
_build_multiphase_gradient(dbf, comps, phases, cur_conds, candidate_site_fracs,
candidate_phase_fracs, candidate_l_constraints,
candidate_constraint_jac, l_multipliers,
callable_dict, phase_records)
# We updated degrees of freedom this iteration
new_l_multipliers = np.linalg.solve(np.dot(constraint_jac, ymat).T,
np.dot(ymat.T, gradient_term + np.dot(l_hessian, step)))
np.clip(new_l_multipliers, -MAX_ABS_LAGRANGE_MULTIPLIER, MAX_ABS_LAGRANGE_MULTIPLIER,
out=new_l_multipliers)
# XXX: Should fix underlying numerical problem at edges of composition space instead of working around
if np.any(np.isnan(new_l_multipliers)):
print('WARNING: Unstable Lagrange multipliers: ', new_l_multipliers)
# Equation 18.16 in Nocedal and Wright
# This method is less accurate but more stable
new_l_multipliers = np.dot(np.dot(np.linalg.inv(np.dot(candidate_constraint_jac,
candidate_constraint_jac.T)),
candidate_constraint_jac), candidate_gradient_term)
np.clip(new_l_multipliers, -MAX_ABS_LAGRANGE_MULTIPLIER, MAX_ABS_LAGRANGE_MULTIPLIER,
out=new_l_multipliers)
l_multipliers = new_l_multipliers
if np.any(np.isnan(l_multipliers)):
print('Invalid l_multipliers after recalculation', l_multipliers)
l_multipliers[:] = 0
if verbose:
print('NEW_L_MULTIPLIERS', l_multipliers)
num_mass_bals = len([i for i in cur_conds.keys() if i.startswith('X_')]) + 1
chemical_potentials = l_multipliers[sum([len(dbf.phases[i].sublattices) for i in phases]):
sum([len(dbf.phases[i].sublattices) for i in phases]) + num_mass_bals]
prop_MU_values[it.multi_index] = chemical_potentials
prop_NP_values[it.multi_index + np.index_exp[:len(phases)]] = candidate_phase_fracs
prop_X_values[it.multi_index + np.index_exp[:len(phases)]] = 0
prop_GM_values[it.multi_index] = candidate_energy
var_offset = 0
for phase_idx in range(len(phases)):
prop_Y_values[it.multi_index + np.index_exp[phase_idx, :phase_dof[phase_idx]]] = \
candidate_site_fracs[var_offset:var_offset + phase_dof[phase_idx]]
for comp_idx, comp in enumerate([c for c in comps if c != 'VA']):
prop_X_values[it.multi_index + np.index_exp[phase_idx, comp_idx]] = \
mole_fractions[(phases[phase_idx], comp)][0](
[candidate_site_fracs[var_offset:var_offset + phase_dof[phase_idx]]])
var_offset += phase_dof[phase_idx]
properties.attrs['solve_iterations'] += 1
total_comp = np.nansum(prop_NP_values[it.multi_index][..., np.newaxis] * \
prop_X_values[it.multi_index], axis=-2)
driving_force = (prop_MU_values[it.multi_index] * total_comp).sum(axis=-1) - \
prop_GM_values[it.multi_index]
driving_force = np.squeeze(driving_force)
if verbose:
print('Chem pot progress', prop_MU_values[it.multi_index] - old_chem_pots)
print('Energy progress', prop_GM_values[it.multi_index] - old_energy)
print('Driving force', driving_force)
no_progress = np.abs(prop_MU_values[it.multi_index] - old_chem_pots).max() < 0.01
no_progress &= np.abs(prop_GM_values[it.multi_index] - old_energy) < MIN_SOLVE_ENERGY_PROGRESS
if no_progress and np.abs(driving_force) > MAX_SOLVE_DRIVING_FORCE:
print('Driving force failed to converge: {}'.format(cur_conds))
prop_MU_values[it.multi_index] = np.nan
prop_NP_values[it.multi_index] = np.nan
prop_X_values[it.multi_index] = np.nan
prop_Y_values[it.multi_index] = np.nan
prop_GM_values[it.multi_index] = np.nan
prop_Phase_values[it.multi_index] = ''
break
elif no_progress:
if verbose:
print('No progress')
num_mass_bals = len([i for i in cur_conds.keys() if i.startswith('X_')]) + 1
chemical_potentials = l_multipliers[sum([len(dbf.phases[i].sublattices) for i in phases]):
sum([len(dbf.phases[i].sublattices) for i in phases]) + num_mass_bals]
prop_MU_values[it.multi_index] = chemical_potentials
break
elif (not no_progress) and cur_iter == MAX_SOLVE_ITERATIONS-1:
print('Failed to converge: {}'.format(cur_conds))
prop_MU_values[it.multi_index] = np.nan
prop_NP_values[it.multi_index] = np.nan
prop_X_values[it.multi_index] = np.nan
prop_Y_values[it.multi_index] = np.nan
prop_GM_values[it.multi_index] = np.nan
prop_Phase_values[it.multi_index] = ''
it.iternext()
return properties
```
<!DOCTYPE html>
<!-- Generated by Cython 0.25.1 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cython: _cython_magic_179ec25e50428c13c53b0ba863f4b74e.pyx</title>
<style type="text/css">
body.cython { font-family: courier; font-size: 12; }
.cython.tag { }
.cython.line { margin: 0em }
.cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }
.cython.line .run { background-color: #B0FFB0; }
.cython.line .mis { background-color: #FFB0B0; }
.cython.code.run { border-left: 8px solid #B0FFB0; }
.cython.code.mis { border-left: 8px solid #FFB0B0; }
.cython.code .py_c_api { color: red; }
.cython.code .py_macro_api { color: #FF7000; }
.cython.code .pyx_c_api { color: #FF3000; }
.cython.code .pyx_macro_api { color: #FF7000; }
.cython.code .refnanny { color: #FFA000; }
.cython.code .trace { color: #FFA000; }
.cython.code .error_goto { color: #FFA000; }
.cython.code .coerce { color: #008000; border: 1px dotted #008000 }
.cython.code .py_attr { color: #FF0000; font-weight: bold; }
.cython.code .c_attr { color: #0000FF; }
.cython.code .py_call { color: #FF0000; font-weight: bold; }
.cython.code .c_call { color: #0000FF; }
.cython.score-0 {background-color: #FFFFff;}
.cython.score-1 {background-color: #FFFFe7;}
.cython.score-2 {background-color: #FFFFd4;}
.cython.score-3 {background-color: #FFFFc4;}
.cython.score-4 {background-color: #FFFFb6;}
.cython.score-5 {background-color: #FFFFaa;}
.cython.score-6 {background-color: #FFFF9f;}
.cython.score-7 {background-color: #FFFF96;}
.cython.score-8 {background-color: #FFFF8d;}
.cython.score-9 {background-color: #FFFF86;}
.cython.score-10 {background-color: #FFFF7f;}
.cython.score-11 {background-color: #FFFF79;}
.cython.score-12 {background-color: #FFFF73;}
.cython.score-13 {background-color: #FFFF6e;}
.cython.score-14 {background-color: #FFFF6a;}
.cython.score-15 {background-color: #FFFF66;}
.cython.score-16 {background-color: #FFFF62;}
.cython.score-17 {background-color: #FFFF5e;}
.cython.score-18 {background-color: #FFFF5b;}
.cython.score-19 {background-color: #FFFF57;}
.cython.score-20 {background-color: #FFFF55;}
.cython.score-21 {background-color: #FFFF52;}
.cython.score-22 {background-color: #FFFF4f;}
.cython.score-23 {background-color: #FFFF4d;}
.cython.score-24 {background-color: #FFFF4b;}
.cython.score-25 {background-color: #FFFF48;}
.cython.score-26 {background-color: #FFFF46;}
.cython.score-27 {background-color: #FFFF44;}
.cython.score-28 {background-color: #FFFF43;}
.cython.score-29 {background-color: #FFFF41;}
.cython.score-30 {background-color: #FFFF3f;}
.cython.score-31 {background-color: #FFFF3e;}
.cython.score-32 {background-color: #FFFF3c;}
.cython.score-33 {background-color: #FFFF3b;}
.cython.score-34 {background-color: #FFFF39;}
.cython.score-35 {background-color: #FFFF38;}
.cython.score-36 {background-color: #FFFF37;}
.cython.score-37 {background-color: #FFFF36;}
.cython.score-38 {background-color: #FFFF35;}
.cython.score-39 {background-color: #FFFF34;}
.cython.score-40 {background-color: #FFFF33;}
.cython.score-41 {background-color: #FFFF32;}
.cython.score-42 {background-color: #FFFF31;}
.cython.score-43 {background-color: #FFFF30;}
.cython.score-44 {background-color: #FFFF2f;}
.cython.score-45 {background-color: #FFFF2e;}
.cython.score-46 {background-color: #FFFF2d;}
.cython.score-47 {background-color: #FFFF2c;}
.cython.score-48 {background-color: #FFFF2b;}
.cython.score-49 {background-color: #FFFF2b;}
.cython.score-50 {background-color: #FFFF2a;}
.cython.score-51 {background-color: #FFFF29;}
.cython.score-52 {background-color: #FFFF29;}
.cython.score-53 {background-color: #FFFF28;}
.cython.score-54 {background-color: #FFFF27;}
.cython.score-55 {background-color: #FFFF27;}
.cython.score-56 {background-color: #FFFF26;}
.cython.score-57 {background-color: #FFFF26;}
.cython.score-58 {background-color: #FFFF25;}
.cython.score-59 {background-color: #FFFF24;}
.cython.score-60 {background-color: #FFFF24;}
.cython.score-61 {background-color: #FFFF23;}
.cython.score-62 {background-color: #FFFF23;}
.cython.score-63 {background-color: #FFFF22;}
.cython.score-64 {background-color: #FFFF22;}
.cython.score-65 {background-color: #FFFF22;}
.cython.score-66 {background-color: #FFFF21;}
.cython.score-67 {background-color: #FFFF21;}
.cython.score-68 {background-color: #FFFF20;}
.cython.score-69 {background-color: #FFFF20;}
.cython.score-70 {background-color: #FFFF1f;}
.cython.score-71 {background-color: #FFFF1f;}
.cython.score-72 {background-color: #FFFF1f;}
.cython.score-73 {background-color: #FFFF1e;}
.cython.score-74 {background-color: #FFFF1e;}
.cython.score-75 {background-color: #FFFF1e;}
.cython.score-76 {background-color: #FFFF1d;}
.cython.score-77 {background-color: #FFFF1d;}
.cython.score-78 {background-color: #FFFF1c;}
.cython.score-79 {background-color: #FFFF1c;}
.cython.score-80 {background-color: #FFFF1c;}
.cython.score-81 {background-color: #FFFF1c;}
.cython.score-82 {background-color: #FFFF1b;}
.cython.score-83 {background-color: #FFFF1b;}
.cython.score-84 {background-color: #FFFF1b;}
.cython.score-85 {background-color: #FFFF1a;}
.cython.score-86 {background-color: #FFFF1a;}
.cython.score-87 {background-color: #FFFF1a;}
.cython.score-88 {background-color: #FFFF1a;}
.cython.score-89 {background-color: #FFFF19;}
.cython.score-90 {background-color: #FFFF19;}
.cython.score-91 {background-color: #FFFF19;}
.cython.score-92 {background-color: #FFFF19;}
.cython.score-93 {background-color: #FFFF18;}
.cython.score-94 {background-color: #FFFF18;}
.cython.score-95 {background-color: #FFFF18;}
.cython.score-96 {background-color: #FFFF18;}
.cython.score-97 {background-color: #FFFF17;}
.cython.score-98 {background-color: #FFFF17;}
.cython.score-99 {background-color: #FFFF17;}
.cython.score-100 {background-color: #FFFF17;}
.cython.score-101 {background-color: #FFFF16;}
.cython.score-102 {background-color: #FFFF16;}
.cython.score-103 {background-color: #FFFF16;}
.cython.score-104 {background-color: #FFFF16;}
.cython.score-105 {background-color: #FFFF16;}
.cython.score-106 {background-color: #FFFF15;}
.cython.score-107 {background-color: #FFFF15;}
.cython.score-108 {background-color: #FFFF15;}
.cython.score-109 {background-color: #FFFF15;}
.cython.score-110 {background-color: #FFFF15;}
.cython.score-111 {background-color: #FFFF15;}
.cython.score-112 {background-color: #FFFF14;}
.cython.score-113 {background-color: #FFFF14;}
.cython.score-114 {background-color: #FFFF14;}
.cython.score-115 {background-color: #FFFF14;}
.cython.score-116 {background-color: #FFFF14;}
.cython.score-117 {background-color: #FFFF14;}
.cython.score-118 {background-color: #FFFF13;}
.cython.score-119 {background-color: #FFFF13;}
.cython.score-120 {background-color: #FFFF13;}
.cython.score-121 {background-color: #FFFF13;}
.cython.score-122 {background-color: #FFFF13;}
.cython.score-123 {background-color: #FFFF13;}
.cython.score-124 {background-color: #FFFF13;}
.cython.score-125 {background-color: #FFFF12;}
.cython.score-126 {background-color: #FFFF12;}
.cython.score-127 {background-color: #FFFF12;}
.cython.score-128 {background-color: #FFFF12;}
.cython.score-129 {background-color: #FFFF12;}
.cython.score-130 {background-color: #FFFF12;}
.cython.score-131 {background-color: #FFFF12;}
.cython.score-132 {background-color: #FFFF11;}
.cython.score-133 {background-color: #FFFF11;}
.cython.score-134 {background-color: #FFFF11;}
.cython.score-135 {background-color: #FFFF11;}
.cython.score-136 {background-color: #FFFF11;}
.cython.score-137 {background-color: #FFFF11;}
.cython.score-138 {background-color: #FFFF11;}
.cython.score-139 {background-color: #FFFF11;}
.cython.score-140 {background-color: #FFFF11;}
.cython.score-141 {background-color: #FFFF10;}
.cython.score-142 {background-color: #FFFF10;}
.cython.score-143 {background-color: #FFFF10;}
.cython.score-144 {background-color: #FFFF10;}
.cython.score-145 {background-color: #FFFF10;}
.cython.score-146 {background-color: #FFFF10;}
.cython.score-147 {background-color: #FFFF10;}
.cython.score-148 {background-color: #FFFF10;}
.cython.score-149 {background-color: #FFFF10;}
.cython.score-150 {background-color: #FFFF0f;}
.cython.score-151 {background-color: #FFFF0f;}
.cython.score-152 {background-color: #FFFF0f;}
.cython.score-153 {background-color: #FFFF0f;}
.cython.score-154 {background-color: #FFFF0f;}
.cython.score-155 {background-color: #FFFF0f;}
.cython.score-156 {background-color: #FFFF0f;}
.cython.score-157 {background-color: #FFFF0f;}
.cython.score-158 {background-color: #FFFF0f;}
.cython.score-159 {background-color: #FFFF0f;}
.cython.score-160 {background-color: #FFFF0f;}
.cython.score-161 {background-color: #FFFF0e;}
.cython.score-162 {background-color: #FFFF0e;}
.cython.score-163 {background-color: #FFFF0e;}
.cython.score-164 {background-color: #FFFF0e;}
.cython.score-165 {background-color: #FFFF0e;}
.cython.score-166 {background-color: #FFFF0e;}
.cython.score-167 {background-color: #FFFF0e;}
.cython.score-168 {background-color: #FFFF0e;}
.cython.score-169 {background-color: #FFFF0e;}
.cython.score-170 {background-color: #FFFF0e;}
.cython.score-171 {background-color: #FFFF0e;}
.cython.score-172 {background-color: #FFFF0e;}
.cython.score-173 {background-color: #FFFF0d;}
.cython.score-174 {background-color: #FFFF0d;}
.cython.score-175 {background-color: #FFFF0d;}
.cython.score-176 {background-color: #FFFF0d;}
.cython.score-177 {background-color: #FFFF0d;}
.cython.score-178 {background-color: #FFFF0d;}
.cython.score-179 {background-color: #FFFF0d;}
.cython.score-180 {background-color: #FFFF0d;}
.cython.score-181 {background-color: #FFFF0d;}
.cython.score-182 {background-color: #FFFF0d;}
.cython.score-183 {background-color: #FFFF0d;}
.cython.score-184 {background-color: #FFFF0d;}
.cython.score-185 {background-color: #FFFF0d;}
.cython.score-186 {background-color: #FFFF0d;}
.cython.score-187 {background-color: #FFFF0c;}
.cython.score-188 {background-color: #FFFF0c;}
.cython.score-189 {background-color: #FFFF0c;}
.cython.score-190 {background-color: #FFFF0c;}
.cython.score-191 {background-color: #FFFF0c;}
.cython.score-192 {background-color: #FFFF0c;}
.cython.score-193 {background-color: #FFFF0c;}
.cython.score-194 {background-color: #FFFF0c;}
.cython.score-195 {background-color: #FFFF0c;}
.cython.score-196 {background-color: #FFFF0c;}
.cython.score-197 {background-color: #FFFF0c;}
.cython.score-198 {background-color: #FFFF0c;}
.cython.score-199 {background-color: #FFFF0c;}
.cython.score-200 {background-color: #FFFF0c;}
.cython.score-201 {background-color: #FFFF0c;}
.cython.score-202 {background-color: #FFFF0c;}
.cython.score-203 {background-color: #FFFF0b;}
.cython.score-204 {background-color: #FFFF0b;}
.cython.score-205 {background-color: #FFFF0b;}
.cython.score-206 {background-color: #FFFF0b;}
.cython.score-207 {background-color: #FFFF0b;}
.cython.score-208 {background-color: #FFFF0b;}
.cython.score-209 {background-color: #FFFF0b;}
.cython.score-210 {background-color: #FFFF0b;}
.cython.score-211 {background-color: #FFFF0b;}
.cython.score-212 {background-color: #FFFF0b;}
.cython.score-213 {background-color: #FFFF0b;}
.cython.score-214 {background-color: #FFFF0b;}
.cython.score-215 {background-color: #FFFF0b;}
.cython.score-216 {background-color: #FFFF0b;}
.cython.score-217 {background-color: #FFFF0b;}
.cython.score-218 {background-color: #FFFF0b;}
.cython.score-219 {background-color: #FFFF0b;}
.cython.score-220 {background-color: #FFFF0b;}
.cython.score-221 {background-color: #FFFF0b;}
.cython.score-222 {background-color: #FFFF0a;}
.cython.score-223 {background-color: #FFFF0a;}
.cython.score-224 {background-color: #FFFF0a;}
.cython.score-225 {background-color: #FFFF0a;}
.cython.score-226 {background-color: #FFFF0a;}
.cython.score-227 {background-color: #FFFF0a;}
.cython.score-228 {background-color: #FFFF0a;}
.cython.score-229 {background-color: #FFFF0a;}
.cython.score-230 {background-color: #FFFF0a;}
.cython.score-231 {background-color: #FFFF0a;}
.cython.score-232 {background-color: #FFFF0a;}
.cython.score-233 {background-color: #FFFF0a;}
.cython.score-234 {background-color: #FFFF0a;}
.cython.score-235 {background-color: #FFFF0a;}
.cython.score-236 {background-color: #FFFF0a;}
.cython.score-237 {background-color: #FFFF0a;}
.cython.score-238 {background-color: #FFFF0a;}
.cython.score-239 {background-color: #FFFF0a;}
.cython.score-240 {background-color: #FFFF0a;}
.cython.score-241 {background-color: #FFFF0a;}
.cython.score-242 {background-color: #FFFF0a;}
.cython.score-243 {background-color: #FFFF0a;}
.cython.score-244 {background-color: #FFFF0a;}
.cython.score-245 {background-color: #FFFF0a;}
.cython.score-246 {background-color: #FFFF09;}
.cython.score-247 {background-color: #FFFF09;}
.cython.score-248 {background-color: #FFFF09;}
.cython.score-249 {background-color: #FFFF09;}
.cython.score-250 {background-color: #FFFF09;}
.cython.score-251 {background-color: #FFFF09;}
.cython.score-252 {background-color: #FFFF09;}
.cython.score-253 {background-color: #FFFF09;}
.cython.score-254 {background-color: #FFFF09;}
.cython .hll { background-color: #ffffcc }
.cython { background: #f8f8f8; }
.cython .c { color: #408080; font-style: italic } /* Comment */
.cython .err { border: 1px solid #FF0000 } /* Error */
.cython .k { color: #008000; font-weight: bold } /* Keyword */
.cython .o { color: #666666 } /* Operator */
.cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cython .cp { color: #BC7A00 } /* Comment.Preproc */
.cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.cython .c1 { color: #408080; font-style: italic } /* Comment.Single */
.cython .cs { color: #408080; font-style: italic } /* Comment.Special */
.cython .gd { color: #A00000 } /* Generic.Deleted */
.cython .ge { font-style: italic } /* Generic.Emph */
.cython .gr { color: #FF0000 } /* Generic.Error */
.cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.cython .gi { color: #00A000 } /* Generic.Inserted */
.cython .go { color: #888888 } /* Generic.Output */
.cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.cython .gs { font-weight: bold } /* Generic.Strong */
.cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.cython .gt { color: #0044DD } /* Generic.Traceback */
.cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.cython .kp { color: #008000 } /* Keyword.Pseudo */
.cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.cython .kt { color: #B00040 } /* Keyword.Type */
.cython .m { color: #666666 } /* Literal.Number */
.cython .s { color: #BA2121 } /* Literal.String */
.cython .na { color: #7D9029 } /* Name.Attribute */
.cython .nb { color: #008000 } /* Name.Builtin */
.cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.cython .no { color: #880000 } /* Name.Constant */
.cython .nd { color: #AA22FF } /* Name.Decorator */
.cython .ni { color: #999999; font-weight: bold } /* Name.Entity */
.cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.cython .nf { color: #0000FF } /* Name.Function */
.cython .nl { color: #A0A000 } /* Name.Label */
.cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.cython .nt { color: #008000; font-weight: bold } /* Name.Tag */
.cython .nv { color: #19177C } /* Name.Variable */
.cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.cython .w { color: #bbbbbb } /* Text.Whitespace */
.cython .mb { color: #666666 } /* Literal.Number.Bin */
.cython .mf { color: #666666 } /* Literal.Number.Float */
.cython .mh { color: #666666 } /* Literal.Number.Hex */
.cython .mi { color: #666666 } /* Literal.Number.Integer */
.cython .mo { color: #666666 } /* Literal.Number.Oct */
.cython .sb { color: #BA2121 } /* Literal.String.Backtick */
.cython .sc { color: #BA2121 } /* Literal.String.Char */
.cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.cython .s2 { color: #BA2121 } /* Literal.String.Double */
.cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.cython .sh { color: #BA2121 } /* Literal.String.Heredoc */
.cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.cython .sx { color: #008000 } /* Literal.String.Other */
.cython .sr { color: #BB6688 } /* Literal.String.Regex */
.cython .s1 { color: #BA2121 } /* Literal.String.Single */
.cython .ss { color: #19177C } /* Literal.String.Symbol */
.cython .bp { color: #008000 } /* Name.Builtin.Pseudo */
.cython .vc { color: #19177C } /* Name.Variable.Class */
.cython .vg { color: #19177C } /* Name.Variable.Global */
.cython .vi { color: #19177C } /* Name.Variable.Instance */
.cython .il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
</head>
<body class="cython">
<p><span style="border-bottom: solid 1px grey;">Generated by Cython 0.25.1</span></p>
<p>
<span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br />
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
<div class="cython"><pre class="cython line score-27" onclick='toggleDiv(this)'>+<span class="">001</span>: <span class="k">import</span> <span class="nn">pycalphad.variables</span> <span class="k">as</span> <span class="nn">v</span></pre>
<pre class='cython code score-27 '> <span class='trace'>__Pyx_TraceLine</span>(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s__33);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s__33);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s__33);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_variables, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_v, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">002</span>: <span class="k">from</span> <span class="nn">pycalphad.core.utils</span> <span class="k">import</span> <span class="n">unpack_kwarg</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(2,0,__PYX_ERR(0, 2, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_kwarg);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_kwarg);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_unpack_kwarg);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_utils, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_unpack_kwarg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_kwarg, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">003</span>: <span class="k">from</span> <span class="nn">pycalphad.core.utils</span> <span class="k">import</span> <span class="n">unpack_condition</span><span class="p">,</span> <span class="n">unpack_phases</span></pre>
<pre class='cython code score-29 '> <span class='trace'>__Pyx_TraceLine</span>(3,0,__PYX_ERR(0, 3, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_condition);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_condition);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_unpack_condition);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_unpack_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_unpack_phases);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 1, __pyx_n_s_unpack_phases);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_utils, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_unpack_condition); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_condition, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_unpack_phases); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_unpack_phases, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">004</span>: <span class="k">from</span> <span class="nn">pycalphad</span> <span class="k">import</span> <span class="n">calculate</span><span class="p">,</span> <span class="n">Model</span></pre>
<pre class='cython code score-29 '> <span class='trace'>__Pyx_TraceLine</span>(4,0,__PYX_ERR(0, 4, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_calculate);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_calculate);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_calculate);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Model);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Model);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 1, __pyx_n_s_Model);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_calculate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_calculate, __pyx_t_2) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_Model); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Model, __pyx_t_2) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">005</span>: <span class="k">from</span> <span class="nn">pycalphad.constraints</span> <span class="k">import</span> <span class="n">mole_fraction</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(5,0,__PYX_ERR(0, 5, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_mole_fraction);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_mole_fraction);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_mole_fraction);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_constraints, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_mole_fraction); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_mole_fraction, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">006</span>: <span class="k">from</span> <span class="nn">pycalphad.core.lower_convex_hull</span> <span class="k">import</span> <span class="n">lower_convex_hull</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(6,0,__PYX_ERR(0, 6, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_lower_convex_hull);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_lower_convex_hull);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_lower_convex_hull);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_lower_convex_hull, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_lower_convex_hull); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_lower_convex_hull, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">007</span>: <span class="k">from</span> <span class="nn">pycalphad.core.sympydiff_utils</span> <span class="k">import</span> <span class="n">build_functions</span> <span class="k">as</span> <span class="n">compiled_build_functions</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(7,0,__PYX_ERR(0, 7, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_build_functions);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_build_functions);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_build_functions);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_sympydiff_utils, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_build_functions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_compiled_build_functions, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">008</span>: <span class="k">from</span> <span class="nn">pycalphad.core.constants</span> <span class="k">import</span> <span class="n">MIN_SITE_FRACTION</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(8,0,__PYX_ERR(0, 8, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_MIN_SITE_FRACTION);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_MIN_SITE_FRACTION);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_MIN_SITE_FRACTION);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_constants, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_MIN_SITE_FRACTION, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">009</span>: <span class="k">from</span> <span class="nn">pycalphad.core.eqsolver</span> <span class="k">import</span> <span class="n">_solve_eq_at_conditions</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(9,0,__PYX_ERR(0, 9, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_solve_eq_at_conditions);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_solve_eq_at_conditions);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_solve_eq_at_conditions);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_eqsolver, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_solve_eq_at_conditions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_solve_eq_at_conditions, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">010</span>: <span class="k">from</span> <span class="nn">sympy</span> <span class="k">import</span> <span class="n">Add</span><span class="p">,</span> <span class="n">Symbol</span></pre>
<pre class='cython code score-29 '> <span class='trace'>__Pyx_TraceLine</span>(10,0,__PYX_ERR(0, 10, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Add);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Add);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_Add);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Symbol);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Symbol);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 1, __pyx_n_s_Symbol);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_sympy, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_Add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Add, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_Symbol); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Symbol, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">011</span>: <span class="k">import</span> <span class="nn">dask</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(11,0,__PYX_ERR(0, 11, __pyx_L1_error))
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">012</span>: <span class="k">from</span> <span class="nn">dask</span> <span class="k">import</span> <span class="n">delayed</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(12,0,__PYX_ERR(0, 12, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_delayed);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_delayed);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_delayed);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_delayed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_delayed, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">013</span>: <span class="k">import</span> <span class="nn">dask.multiprocessing</span><span class="o">,</span> <span class="nn">dask.async</span></pre>
<pre class='cython code score-16 '> <span class='trace'>__Pyx_TraceLine</span>(13,0,__PYX_ERR(0, 13, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask_multiprocessing, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_dask_async, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_dask, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">014</span>: <span class="k">from</span> <span class="nn">xarray</span> <span class="k">import</span> <span class="n">Dataset</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(14,0,__PYX_ERR(0, 14, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_Dataset);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_Dataset);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_Dataset);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_xarray, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_Dataset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_Dataset, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">015</span>: <span class="k">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(15,0,__PYX_ERR(0, 15, __pyx_L1_error))
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">016</span>: <span class="k">cimport</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span></pre>
<pre class="cython line score-29" onclick='toggleDiv(this)'>+<span class="">017</span>: <span class="k">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">namedtuple</span><span class="p">,</span> <span class="n">OrderedDict</span></pre>
<pre class='cython code score-29 '>
/* "_cython_magic_179ec25e50428c13c53b0ba863f4b74e.pyx":17
* import numpy as np
* cimport numpy as np
* from collections import namedtuple, OrderedDict # <<<<<<<<<<<<<<
* from datetime import datetime
* from pycalphad.core.eqsolver import *
*/
<span class='trace'>__Pyx_TraceLine</span>(17,0,__PYX_ERR(0, 17, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_namedtuple);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_namedtuple);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s_namedtuple);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_OrderedDict);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_OrderedDict);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 1, __pyx_n_s_OrderedDict);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_collections, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_namedtuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_namedtuple, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_2, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">018</span>: <span class="k">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(18,0,__PYX_ERR(0, 18, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_datetime);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_datetime);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_datetime);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_datetime, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_datetime, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-11" onclick='toggleDiv(this)'>+<span class="">019</span>: <span class="k">from</span> <span class="nn">pycalphad.core.eqsolver</span> <span class="k">import</span> <span class="o">*</span></pre>
<pre class='cython code score-11 '> <span class='trace'>__Pyx_TraceLine</span>(19,0,__PYX_ERR(0, 19, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s__33);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s__33);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_1, 0, __pyx_n_s__33);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_eqsolver, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_import_star(__pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-59" onclick='toggleDiv(this)'>+<span class="">020</span>: <span class="k">from</span> <span class="nn">pycalphad.core.eqsolver</span> <span class="k">import</span> <span class="n">_build_multiphase_gradient</span><span class="p">,</span> \</pre>
<pre class='cython code score-59 '> <span class='trace'>__Pyx_TraceLine</span>(20,0,__PYX_ERR(0, 20, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyList_New</span>(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_build_multiphase_gradient);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_build_multiphase_gradient);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 0, __pyx_n_s_build_multiphase_gradient);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_build_multiphase_system);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_build_multiphase_system);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 1, __pyx_n_s_build_multiphase_system);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_compute_constraints);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_compute_constraints);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 2, __pyx_n_s_compute_constraints);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_compute_phase_dof);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_compute_phase_dof);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 3, __pyx_n_s_compute_phase_dof);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_s_remove_degenerate_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_s_remove_degenerate_phases);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_2, 4, __pyx_n_s_remove_degenerate_phases);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_pycalphad_core_eqsolver, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_build_multiphase_gradient); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_build_multiphase_gradient, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_build_multiphase_system); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_build_multiphase_system, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_compute_constraints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_compute_constraints, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_compute_phase_dof); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_compute_phase_dof, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_ImportFrom</span>(__pyx_t_1, __pyx_n_s_remove_degenerate_phases); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_remove_degenerate_phases, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">021</span>: <span class="n">_build_multiphase_system</span><span class="p">,</span> <span class="n">_compute_constraints</span><span class="p">,</span> <span class="n">_compute_phase_dof</span><span class="p">,</span> <span class="n">remove_degenerate_phases</span></pre>
<pre class="cython line score-0"> <span class="">022</span>: <span class="k">cimport</span> <span class="nn">cython</span></pre>
<pre class="cython line score-0"> <span class="">023</span>: </pre>
<pre class="cython line score-220" onclick='toggleDiv(this)'>+<span class="">024</span>: <span class="k">def</span> <span class="nf">_solve_eq_at_conditions</span><span class="p">(</span><span class="n">dbf</span><span class="p">,</span> <span class="n">comps</span><span class="p">,</span> <span class="n">properties</span><span class="p">,</span> <span class="n">phase_records</span><span class="p">,</span> <span class="n">callable_dict</span><span class="p">,</span> <span class="n">conds_keys</span><span class="p">,</span> <span class="n">verbose</span><span class="p">):</span></pre>
<pre class='cython code score-220 '>/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e_1_solve_eq_at_conditions(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e__solve_eq_at_conditions[] = "\n Compute equilibrium for the given conditions.\n This private function is meant to be called from a worker subprocess.\n For that case, usually only a small slice of the master 'properties' is provided.\n Since that slice will be copied, we also return the modified 'properties'.\n\n Parameters\n ----------\n dbf : Database\n Thermodynamic database containing the relevant parameters.\n comps : list\n Names of components to consider in the calculation.\n properties : Dataset\n Will be modified! Thermodynamic properties and conditions.\n phase_records : dict of PhaseRecord\n Details on phase callables.\n callable_dict : dict of callable\n Objective functions for each phase.\n conds_keys : list of str\n List of conditions axes in dimension order.\n verbose : bool\n Print details.\n\n Returns\n -------\n properties : Dataset\n Modified with equilibrium values.\n ";
static PyMethodDef __pyx_mdef_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e_1_solve_eq_at_conditions = {"_solve_eq_at_conditions", (PyCFunction)__pyx_pw_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e_1_solve_eq_at_conditions, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e__solve_eq_at_conditions};
static PyObject *__pyx_pw_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e_1_solve_eq_at_conditions(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_dbf = 0;
PyObject *__pyx_v_comps = 0;
PyObject *__pyx_v_properties = 0;
PyObject *__pyx_v_phase_records = 0;
PyObject *__pyx_v_callable_dict = 0;
PyObject *__pyx_v_conds_keys = 0;
PyObject *__pyx_v_verbose = 0;
PyObject *__pyx_r = 0;
<span class='refnanny'>__Pyx_RefNannyDeclarations</span>
<span class='refnanny'>__Pyx_RefNannySetupContext</span>("_solve_eq_at_conditions (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dbf,&__pyx_n_s_comps,&__pyx_n_s_properties,&__pyx_n_s_phase_records,&__pyx_n_s_callable_dict,&__pyx_n_s_conds_keys,&__pyx_n_s_verbose,0};
PyObject* values[7] = {0,0,0,0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args);
switch (pos_args) {
case 7: values[6] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 6);
case 6: values[5] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 5);
case 5: values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
case 4: values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
case 3: values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
case 2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_dbf)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_comps)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 1); __PYX_ERR(0, 24, __pyx_L3_error)
}
case 2:
if (likely((values[2] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_properties)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 2); __PYX_ERR(0, 24, __pyx_L3_error)
}
case 3:
if (likely((values[3] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_phase_records)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 3); __PYX_ERR(0, 24, __pyx_L3_error)
}
case 4:
if (likely((values[4] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_callable_dict)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 4); __PYX_ERR(0, 24, __pyx_L3_error)
}
case 5:
if (likely((values[5] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_conds_keys)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 5); __PYX_ERR(0, 24, __pyx_L3_error)
}
case 6:
if (likely((values[6] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_verbose)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, 6); __PYX_ERR(0, 24, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_solve_eq_at_conditions") < 0)) __PYX_ERR(0, 24, __pyx_L3_error)
}
} else if (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args) != 7) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
values[5] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 5);
values[6] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 6);
}
__pyx_v_dbf = values[0];
__pyx_v_comps = values[1];
__pyx_v_properties = values[2];
__pyx_v_phase_records = values[3];
__pyx_v_callable_dict = values[4];
__pyx_v_conds_keys = values[5];
__pyx_v_verbose = values[6];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("_solve_eq_at_conditions", 1, 7, 7, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); __PYX_ERR(0, 24, __pyx_L3_error)
__pyx_L3_error:;
<span class='pyx_c_api'>__Pyx_AddTraceback</span>("_cython_magic_179ec25e50428c13c53b0ba863f4b74e._solve_eq_at_conditions", __pyx_clineno, __pyx_lineno, __pyx_filename);
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e__solve_eq_at_conditions(__pyx_self, __pyx_v_dbf, __pyx_v_comps, __pyx_v_properties, __pyx_v_phase_records, __pyx_v_callable_dict, __pyx_v_conds_keys, __pyx_v_verbose);
/* function exit code */
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return __pyx_r;
}
static PyObject *__pyx_pf_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e__solve_eq_at_conditions(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dbf, PyObject *__pyx_v_comps, PyObject *__pyx_v_properties, PyObject *__pyx_v_phase_records, PyObject *__pyx_v_callable_dict, PyObject *__pyx_v_conds_keys, PyObject *__pyx_v_verbose) {
double __pyx_v_indep_sum;
int __pyx_v_num_phases;
CYTHON_UNUSED int __pyx_v_num_vars;
int __pyx_v_cur_iter;
int __pyx_v_old_phase_length;
int __pyx_v_new_phase_length;
int __pyx_v_var_idx;
int __pyx_v_sfidx;
int __pyx_v_pfidx;
int __pyx_v_m;
int __pyx_v_n;
PyArrayObject *__pyx_v_gradient_term = 0;
PyArrayObject *__pyx_v_p_y = 0;
PyArrayObject *__pyx_v_l_constraints = 0;
PyArrayObject *__pyx_v_step = 0;
PyArrayObject *__pyx_v_site_fracs = 0;
PyArrayObject *__pyx_v_candidate_site_fracs = 0;
PyArrayObject *__pyx_v_l_multipliers = 0;
PyArrayObject *__pyx_v_new_l_multipliers = 0;
PyArrayObject *__pyx_v_candidate_phase_fracs = 0;
PyArrayObject *__pyx_v_phase_fracs = 0;
PyArrayObject *__pyx_v_l_hessian = 0;
PyArrayObject *__pyx_v_ymat = 0;
PyArrayObject *__pyx_v_zmat = 0;
PyArrayObject *__pyx_v_qmat = 0;
PyArrayObject *__pyx_v_rmat = 0;
PyArrayObject *__pyx_v_constraint_jac = 0;
PyObject *__pyx_v_prop_MU_values = NULL;
PyObject *__pyx_v_prop_NP_values = NULL;
PyObject *__pyx_v_prop_Phase_values = NULL;
PyObject *__pyx_v_prop_X_values = NULL;
PyObject *__pyx_v_prop_Y_values = NULL;
PyObject *__pyx_v_prop_GM_values = NULL;
PyObject *__pyx_v_it = NULL;
PyObject *__pyx_v_cur_conds = NULL;
PyObject *__pyx_v_dependent_comp = NULL;
PyObject *__pyx_v_mole_fractions = NULL;
PyObject *__pyx_v_phases = NULL;
PyObject *__pyx_v_zero_dof = NULL;
PyObject *__pyx_v_phase_dof = NULL;
PyObject *__pyx_v_name = NULL;
Py_ssize_t __pyx_v_idx;
PyObject *__pyx_v_active_in_subl = NULL;
PyObject *__pyx_v_ais = NULL;
PyObject *__pyx_v_constraint_hess = NULL;
PyObject *__pyx_v_p_z = NULL;
PyObject *__pyx_v_old_energy = NULL;
PyObject *__pyx_v_old_chem_pots = NULL;
PyObject *__pyx_v_candidate_l_constraints = NULL;
PyObject *__pyx_v_candidate_constraint_jac = NULL;
CYTHON_UNUSED PyObject *__pyx_v_candidate_constraint_hess = NULL;
PyObject *__pyx_v_candidate_energy = NULL;
PyObject *__pyx_v_candidate_gradient_term = NULL;
PyObject *__pyx_v_num_mass_bals = NULL;
PyObject *__pyx_v_chemical_potentials = NULL;
PyObject *__pyx_v_var_offset = NULL;
Py_ssize_t __pyx_v_phase_idx;
PyObject *__pyx_v_comp_idx = NULL;
PyObject *__pyx_v_comp = NULL;
PyObject *__pyx_v_total_comp = NULL;
PyObject *__pyx_v_driving_force = NULL;
PyObject *__pyx_v_no_progress = NULL;
__Pyx_LocalBuf_ND __pyx_pybuffernd_candidate_phase_fracs;
__Pyx_Buffer __pyx_pybuffer_candidate_phase_fracs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_candidate_site_fracs;
__Pyx_Buffer __pyx_pybuffer_candidate_site_fracs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_constraint_jac;
__Pyx_Buffer __pyx_pybuffer_constraint_jac;
__Pyx_LocalBuf_ND __pyx_pybuffernd_gradient_term;
__Pyx_Buffer __pyx_pybuffer_gradient_term;
__Pyx_LocalBuf_ND __pyx_pybuffernd_l_constraints;
__Pyx_Buffer __pyx_pybuffer_l_constraints;
__Pyx_LocalBuf_ND __pyx_pybuffernd_l_hessian;
__Pyx_Buffer __pyx_pybuffer_l_hessian;
__Pyx_LocalBuf_ND __pyx_pybuffernd_l_multipliers;
__Pyx_Buffer __pyx_pybuffer_l_multipliers;
__Pyx_LocalBuf_ND __pyx_pybuffernd_new_l_multipliers;
__Pyx_Buffer __pyx_pybuffer_new_l_multipliers;
__Pyx_LocalBuf_ND __pyx_pybuffernd_p_y;
__Pyx_Buffer __pyx_pybuffer_p_y;
__Pyx_LocalBuf_ND __pyx_pybuffernd_phase_fracs;
__Pyx_Buffer __pyx_pybuffer_phase_fracs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_qmat;
__Pyx_Buffer __pyx_pybuffer_qmat;
__Pyx_LocalBuf_ND __pyx_pybuffernd_rmat;
__Pyx_Buffer __pyx_pybuffer_rmat;
__Pyx_LocalBuf_ND __pyx_pybuffernd_site_fracs;
__Pyx_Buffer __pyx_pybuffer_site_fracs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_step;
__Pyx_Buffer __pyx_pybuffer_step;
__Pyx_LocalBuf_ND __pyx_pybuffernd_ymat;
__Pyx_Buffer __pyx_pybuffer_ymat;
__Pyx_LocalBuf_ND __pyx_pybuffernd_zmat;
__Pyx_Buffer __pyx_pybuffer_zmat;
PyObject *__pyx_r = NULL;
<span class='trace'>__Pyx_TraceDeclarations</span>
<span class='trace'>__Pyx_TraceFrameInit</span>(__pyx_codeobj_)
<span class='refnanny'>__Pyx_RefNannyDeclarations</span>
<span class='refnanny'>__Pyx_RefNannySetupContext</span>("_solve_eq_at_conditions", 0);
<span class='trace'>__Pyx_TraceCall</span>("_solve_eq_at_conditions", __pyx_f[0], 24, 0, __PYX_ERR(0, 24, __pyx_L1_error));
__pyx_pybuffer_gradient_term.pybuffer.buf = NULL;
__pyx_pybuffer_gradient_term.refcount = 0;
__pyx_pybuffernd_gradient_term.data = NULL;
__pyx_pybuffernd_gradient_term.rcbuffer = &__pyx_pybuffer_gradient_term;
__pyx_pybuffer_p_y.pybuffer.buf = NULL;
__pyx_pybuffer_p_y.refcount = 0;
__pyx_pybuffernd_p_y.data = NULL;
__pyx_pybuffernd_p_y.rcbuffer = &__pyx_pybuffer_p_y;
__pyx_pybuffer_l_constraints.pybuffer.buf = NULL;
__pyx_pybuffer_l_constraints.refcount = 0;
__pyx_pybuffernd_l_constraints.data = NULL;
__pyx_pybuffernd_l_constraints.rcbuffer = &__pyx_pybuffer_l_constraints;
__pyx_pybuffer_step.pybuffer.buf = NULL;
__pyx_pybuffer_step.refcount = 0;
__pyx_pybuffernd_step.data = NULL;
__pyx_pybuffernd_step.rcbuffer = &__pyx_pybuffer_step;
__pyx_pybuffer_site_fracs.pybuffer.buf = NULL;
__pyx_pybuffer_site_fracs.refcount = 0;
__pyx_pybuffernd_site_fracs.data = NULL;
__pyx_pybuffernd_site_fracs.rcbuffer = &__pyx_pybuffer_site_fracs;
__pyx_pybuffer_candidate_site_fracs.pybuffer.buf = NULL;
__pyx_pybuffer_candidate_site_fracs.refcount = 0;
__pyx_pybuffernd_candidate_site_fracs.data = NULL;
__pyx_pybuffernd_candidate_site_fracs.rcbuffer = &__pyx_pybuffer_candidate_site_fracs;
__pyx_pybuffer_l_multipliers.pybuffer.buf = NULL;
__pyx_pybuffer_l_multipliers.refcount = 0;
__pyx_pybuffernd_l_multipliers.data = NULL;
__pyx_pybuffernd_l_multipliers.rcbuffer = &__pyx_pybuffer_l_multipliers;
__pyx_pybuffer_new_l_multipliers.pybuffer.buf = NULL;
__pyx_pybuffer_new_l_multipliers.refcount = 0;
__pyx_pybuffernd_new_l_multipliers.data = NULL;
__pyx_pybuffernd_new_l_multipliers.rcbuffer = &__pyx_pybuffer_new_l_multipliers;
__pyx_pybuffer_candidate_phase_fracs.pybuffer.buf = NULL;
__pyx_pybuffer_candidate_phase_fracs.refcount = 0;
__pyx_pybuffernd_candidate_phase_fracs.data = NULL;
__pyx_pybuffernd_candidate_phase_fracs.rcbuffer = &__pyx_pybuffer_candidate_phase_fracs;
__pyx_pybuffer_phase_fracs.pybuffer.buf = NULL;
__pyx_pybuffer_phase_fracs.refcount = 0;
__pyx_pybuffernd_phase_fracs.data = NULL;
__pyx_pybuffernd_phase_fracs.rcbuffer = &__pyx_pybuffer_phase_fracs;
__pyx_pybuffer_l_hessian.pybuffer.buf = NULL;
__pyx_pybuffer_l_hessian.refcount = 0;
__pyx_pybuffernd_l_hessian.data = NULL;
__pyx_pybuffernd_l_hessian.rcbuffer = &__pyx_pybuffer_l_hessian;
__pyx_pybuffer_ymat.pybuffer.buf = NULL;
__pyx_pybuffer_ymat.refcount = 0;
__pyx_pybuffernd_ymat.data = NULL;
__pyx_pybuffernd_ymat.rcbuffer = &__pyx_pybuffer_ymat;
__pyx_pybuffer_zmat.pybuffer.buf = NULL;
__pyx_pybuffer_zmat.refcount = 0;
__pyx_pybuffernd_zmat.data = NULL;
__pyx_pybuffernd_zmat.rcbuffer = &__pyx_pybuffer_zmat;
__pyx_pybuffer_qmat.pybuffer.buf = NULL;
__pyx_pybuffer_qmat.refcount = 0;
__pyx_pybuffernd_qmat.data = NULL;
__pyx_pybuffernd_qmat.rcbuffer = &__pyx_pybuffer_qmat;
__pyx_pybuffer_rmat.pybuffer.buf = NULL;
__pyx_pybuffer_rmat.refcount = 0;
__pyx_pybuffernd_rmat.data = NULL;
__pyx_pybuffernd_rmat.rcbuffer = &__pyx_pybuffer_rmat;
__pyx_pybuffer_constraint_jac.pybuffer.buf = NULL;
__pyx_pybuffer_constraint_jac.refcount = 0;
__pyx_pybuffernd_constraint_jac.data = NULL;
__pyx_pybuffernd_constraint_jac.rcbuffer = &__pyx_pybuffer_constraint_jac;
/* … */
/* function exit code */
__pyx_L1_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_31);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_45);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
<span class='pyx_c_api'>__Pyx_ErrFetch</span>(&__pyx_type, &__pyx_value, &__pyx_tb);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_gradient_term.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_constraints.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_hessian.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_p_y.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_qmat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_rmat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_ymat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_zmat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_ErrRestore</span>(__pyx_type, __pyx_value, __pyx_tb);}
<span class='pyx_c_api'>__Pyx_AddTraceback</span>("_cython_magic_179ec25e50428c13c53b0ba863f4b74e._solve_eq_at_conditions", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
goto __pyx_L2;
__pyx_L0:;
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_gradient_term.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_constraints.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_hessian.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_p_y.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_qmat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_rmat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_ymat.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_zmat.rcbuffer->pybuffer);
__pyx_L2:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_gradient_term);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_p_y);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_l_constraints);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_step);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_site_fracs);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_candidate_site_fracs);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_l_multipliers);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_new_l_multipliers);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_candidate_phase_fracs);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_phase_fracs);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_l_hessian);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_ymat);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_zmat);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_qmat);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_rmat);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>((PyObject *)__pyx_v_constraint_jac);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_MU_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_NP_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_Phase_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_X_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_Y_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_prop_GM_values);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_it);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_cur_conds);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_dependent_comp);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_mole_fractions);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_phases);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_zero_dof);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_phase_dof);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_name);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_active_in_subl);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_ais);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_constraint_hess);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_p_z);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_old_energy);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_old_chem_pots);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_candidate_l_constraints);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_candidate_constraint_jac);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_candidate_constraint_hess);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_candidate_energy);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_candidate_gradient_term);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_num_mass_bals);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_chemical_potentials);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_var_offset);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_comp_idx);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_comp);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_total_comp);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_driving_force);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_v_no_progress);
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);
<span class='trace'>__Pyx_TraceReturn</span>(__pyx_r, 0);
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return __pyx_r;
}
/* … */
__pyx_tuple__34 = <span class='py_c_api'>PyTuple_Pack</span>(69, __pyx_n_s_dbf, __pyx_n_s_comps, __pyx_n_s_properties, __pyx_n_s_phase_records, __pyx_n_s_callable_dict, __pyx_n_s_conds_keys, __pyx_n_s_verbose, __pyx_n_s_indep_sum, __pyx_n_s_num_phases, __pyx_n_s_num_vars, __pyx_n_s_cur_iter, __pyx_n_s_old_phase_length, __pyx_n_s_new_phase_length, __pyx_n_s_var_idx, __pyx_n_s_sfidx, __pyx_n_s_pfidx, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_gradient_term, __pyx_n_s_p_y, __pyx_n_s_l_constraints, __pyx_n_s_step, __pyx_n_s_site_fracs, __pyx_n_s_candidate_site_fracs, __pyx_n_s_l_multipliers, __pyx_n_s_new_l_multipliers, __pyx_n_s_candidate_phase_fracs, __pyx_n_s_phase_fracs, __pyx_n_s_l_hessian, __pyx_n_s_ymat, __pyx_n_s_zmat, __pyx_n_s_qmat, __pyx_n_s_rmat, __pyx_n_s_constraint_jac, __pyx_n_s_prop_MU_values, __pyx_n_s_prop_NP_values, __pyx_n_s_prop_Phase_values, __pyx_n_s_prop_X_values, __pyx_n_s_prop_Y_values, __pyx_n_s_prop_GM_values, __pyx_n_s_it, __pyx_n_s_cur_conds, __pyx_n_s_dependent_comp, __pyx_n_s_mole_fractions, __pyx_n_s_phases, __pyx_n_s_zero_dof, __pyx_n_s_phase_dof, __pyx_n_s_name, __pyx_n_s_idx, __pyx_n_s_active_in_subl, __pyx_n_s_ais, __pyx_n_s_constraint_hess, __pyx_n_s_p_z, __pyx_n_s_old_energy, __pyx_n_s_old_chem_pots, __pyx_n_s_candidate_l_constraints, __pyx_n_s_candidate_constraint_jac, __pyx_n_s_candidate_constraint_hess, __pyx_n_s_candidate_energy, __pyx_n_s_candidate_gradient_term, __pyx_n_s_num_mass_bals, __pyx_n_s_chemical_potentials, __pyx_n_s_var_offset, __pyx_n_s_phase_idx, __pyx_n_s_comp_idx, __pyx_n_s_comp, __pyx_n_s_total_comp, __pyx_n_s_driving_force, __pyx_n_s_no_progress); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 24, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__34);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__34);
/* … */
<span class='trace'>__Pyx_TraceLine</span>(24,0,__PYX_ERR(0, 24, __pyx_L1_error))
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_CyFunction_NewEx</span>(&__pyx_mdef_46_cython_magic_179ec25e50428c13c53b0ba863f4b74e_1_solve_eq_at_conditions, 0, __pyx_n_s_solve_eq_at_conditions, NULL, __pyx_n_s_cython_magic_179ec25e50428c13c5, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_solve_eq_at_conditions, __pyx_t_1) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">025</span>: <span class="sd">"""</span></pre>
<pre class="cython line score-0"> <span class="">026</span>: <span class="sd"> Compute equilibrium for the given conditions.</span></pre>
<pre class="cython line score-0"> <span class="">027</span>: <span class="sd"> This private function is meant to be called from a worker subprocess.</span></pre>
<pre class="cython line score-0"> <span class="">028</span>: <span class="sd"> For that case, usually only a small slice of the master 'properties' is provided.</span></pre>
<pre class="cython line score-0"> <span class="">029</span>: <span class="sd"> Since that slice will be copied, we also return the modified 'properties'.</span></pre>
<pre class="cython line score-0"> <span class="">030</span>: </pre>
<pre class="cython line score-0"> <span class="">031</span>: <span class="sd"> Parameters</span></pre>
<pre class="cython line score-0"> <span class="">032</span>: <span class="sd"> ----------</span></pre>
<pre class="cython line score-0"> <span class="">033</span>: <span class="sd"> dbf : Database</span></pre>
<pre class="cython line score-0"> <span class="">034</span>: <span class="sd"> Thermodynamic database containing the relevant parameters.</span></pre>
<pre class="cython line score-0"> <span class="">035</span>: <span class="sd"> comps : list</span></pre>
<pre class="cython line score-0"> <span class="">036</span>: <span class="sd"> Names of components to consider in the calculation.</span></pre>
<pre class="cython line score-0"> <span class="">037</span>: <span class="sd"> properties : Dataset</span></pre>
<pre class="cython line score-0"> <span class="">038</span>: <span class="sd"> Will be modified! Thermodynamic properties and conditions.</span></pre>
<pre class="cython line score-0"> <span class="">039</span>: <span class="sd"> phase_records : dict of PhaseRecord</span></pre>
<pre class="cython line score-0"> <span class="">040</span>: <span class="sd"> Details on phase callables.</span></pre>
<pre class="cython line score-0"> <span class="">041</span>: <span class="sd"> callable_dict : dict of callable</span></pre>
<pre class="cython line score-0"> <span class="">042</span>: <span class="sd"> Objective functions for each phase.</span></pre>
<pre class="cython line score-0"> <span class="">043</span>: <span class="sd"> conds_keys : list of str</span></pre>
<pre class="cython line score-0"> <span class="">044</span>: <span class="sd"> List of conditions axes in dimension order.</span></pre>
<pre class="cython line score-0"> <span class="">045</span>: <span class="sd"> verbose : bool</span></pre>
<pre class="cython line score-0"> <span class="">046</span>: <span class="sd"> Print details.</span></pre>
<pre class="cython line score-0"> <span class="">047</span>: </pre>
<pre class="cython line score-0"> <span class="">048</span>: <span class="sd"> Returns</span></pre>
<pre class="cython line score-0"> <span class="">049</span>: <span class="sd"> -------</span></pre>
<pre class="cython line score-0"> <span class="">050</span>: <span class="sd"> properties : Dataset</span></pre>
<pre class="cython line score-0"> <span class="">051</span>: <span class="sd"> Modified with equilibrium values.</span></pre>
<pre class="cython line score-0"> <span class="">052</span>: <span class="sd"> """</span></pre>
<pre class="cython line score-0"> <span class="">053</span>: <span class="k">cdef</span><span class="p">:</span></pre>
<pre class="cython line score-0"> <span class="">054</span>: <span class="n">double</span> <span class="n">indep_sum</span></pre>
<pre class="cython line score-0"> <span class="">055</span>: <span class="nb">int</span> <span class="n">num_phases</span><span class="p">,</span> <span class="n">num_vars</span><span class="p">,</span> <span class="n">cur_iter</span><span class="p">,</span> <span class="n">old_phase_length</span><span class="p">,</span> <span class="n">new_phase_length</span><span class="p">,</span> <span class="n">var_idx</span><span class="p">,</span> <span class="n">sfidx</span><span class="p">,</span> <span class="n">pfidx</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">n</span></pre>
<pre class="cython line score-0"> <span class="">056</span>: <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">[</span><span class="n">ndim</span><span class="o">=</span><span class="mf">1</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64_t</span><span class="p">]</span> <span class="n">gradient_term</span><span class="p">,</span> <span class="n">p_y</span><span class="p">,</span> <span class="n">l_constraints</span><span class="p">,</span> <span class="n">step</span></pre>
<pre class="cython line score-0"> <span class="">057</span>: <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">[</span><span class="n">ndim</span><span class="o">=</span><span class="mf">1</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64_t</span><span class="p">]</span> <span class="n">site_fracs</span><span class="p">,</span> <span class="n">candidate_site_fracs</span><span class="p">,</span> <span class="n">l_multipliers</span><span class="p">,</span> <span class="n">new_l_multipliers</span><span class="p">,</span> <span class="n">candidate_phase_fracs</span><span class="p">,</span> <span class="n">phase_fracs</span></pre>
<pre class="cython line score-0"> <span class="">058</span>: <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">[</span><span class="n">ndim</span><span class="o">=</span><span class="mf">2</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64_t</span><span class="p">]</span> <span class="n">l_hessian</span><span class="p">,</span> <span class="n">ymat</span><span class="p">,</span> <span class="n">zmat</span><span class="p">,</span> <span class="n">qmat</span><span class="p">,</span> <span class="n">rmat</span><span class="p">,</span> <span class="n">constraint_jac</span></pre>
<pre class="cython line score-0"> <span class="">059</span>: <span class="c"># Factored out via profiling</span></pre>
<pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">060</span>: <span class="n">prop_MU_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'MU'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(60,0,__PYX_ERR(0, 60, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_MU); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_prop_MU_values = __pyx_t_2;
__pyx_t_2 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">061</span>: <span class="n">prop_NP_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'NP'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(61,0,__PYX_ERR(0, 61, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_NP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_prop_NP_values = __pyx_t_1;
__pyx_t_1 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">062</span>: <span class="n">prop_Phase_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'Phase'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(62,0,__PYX_ERR(0, 62, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_Phase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_prop_Phase_values = __pyx_t_2;
__pyx_t_2 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">063</span>: <span class="n">prop_X_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'X'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(63,0,__PYX_ERR(0, 63, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_X); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_prop_X_values = __pyx_t_1;
__pyx_t_1 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">064</span>: <span class="n">prop_Y_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'Y'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(64,0,__PYX_ERR(0, 64, __pyx_L1_error))
__pyx_t_1 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_Y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_prop_Y_values = __pyx_t_2;
__pyx_t_2 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">065</span>: <span class="n">prop_GM_values</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'GM'</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(65,0,__PYX_ERR(0, 65, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_GM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_prop_GM_values = __pyx_t_1;
__pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">066</span>: </pre>
<pre class="cython line score-35" onclick='toggleDiv(this)'>+<span class="">067</span>: <span class="n">it</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nditer</span><span class="p">(</span><span class="n">prop_GM_values</span><span class="p">,</span> <span class="n">flags</span><span class="o">=</span><span class="p">[</span><span class="s">'multi_index'</span><span class="p">])</span></pre>
<pre class='cython code score-35 '> <span class='trace'>__Pyx_TraceLine</span>(67,0,__PYX_ERR(0, 67, __pyx_L1_error))
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_nditer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_prop_GM_values);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_prop_GM_values);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 0, __pyx_v_prop_GM_values);
__pyx_t_3 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_u_multi_index);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_u_multi_index);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_4, 0, __pyx_n_u_multi_index);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_3, __pyx_n_s_flags, __pyx_t_4) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_it = __pyx_t_4;
__pyx_t_4 = 0;
</pre><pre class="cython line score-0"> <span class="">068</span>: </pre>
<pre class="cython line score-0"> <span class="">069</span>: <span class="c">#if verbose:</span></pre>
<pre class="cython line score-0"> <span class="">070</span>: <span class="c"># print('INITIAL CONFIGURATION')</span></pre>
<pre class="cython line score-0"> <span class="">071</span>: <span class="c"># print(properties.MU)</span></pre>
<pre class="cython line score-0"> <span class="">072</span>: <span class="c"># print(properties.Phase)</span></pre>
<pre class="cython line score-0"> <span class="">073</span>: <span class="c"># print(properties.NP)</span></pre>
<pre class="cython line score-0"> <span class="">074</span>: <span class="c"># print(properties.X)</span></pre>
<pre class="cython line score-0"> <span class="">075</span>: <span class="c"># print(properties.Y)</span></pre>
<pre class="cython line score-0"> <span class="">076</span>: <span class="c"># print('---------------------')</span></pre>
<pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">077</span>: <span class="k">while</span> <span class="ow">not</span> <span class="n">it</span><span class="o">.</span><span class="n">finished</span><span class="p">:</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(77,0,__PYX_ERR(0, 77, __pyx_L1_error))
while (1) {
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_finished); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 77, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_6 = ((!__pyx_t_5) != 0);
if (!__pyx_t_6) break;
</pre><pre class="cython line score-0"> <span class="">078</span>: <span class="c"># A lot of this code relies on cur_conds being ordered!</span></pre>
<pre class="cython line score-53" onclick='toggleDiv(this)'>+<span class="">079</span>: <span class="n">cur_conds</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">conds_keys</span><span class="p">,</span></pre>
<pre class='cython code score-53 '> <span class='trace'>__Pyx_TraceLine</span>(79,0,__PYX_ERR(0, 79, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
{ /* enter inner scope */
PyObject *__pyx_7genexpr__pyx_v_a = NULL;
PyObject *__pyx_7genexpr__pyx_v_b = NULL;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(79,0,__PYX_ERR(0, 79, __pyx_L1_error))
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_conds_keys);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_conds_keys);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_v_conds_keys);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_zip, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_7) {
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_1};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
{
__pyx_t_14 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0+1, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_cur_conds, __pyx_t_4);
__pyx_t_4 = 0;
</pre><pre class="cython line score-60" onclick='toggleDiv(this)'>+<span class="">080</span>: <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">properties</span><span class="p">[</span><span class="s">'GM'</span><span class="p">]</span><span class="o">.</span><span class="n">coords</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="n">a</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">)</span></pre>
<pre class='cython code score-60 '> <span class='trace'>__Pyx_TraceLine</span>(80,0,__PYX_ERR(0, 80, __pyx_L7_error))
__pyx_t_1 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
/* … */
<span class='trace'>__Pyx_TraceLine</span>(80,0,__PYX_ERR(0, 80, __pyx_L7_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_GM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_coords); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_10, __pyx_7genexpr__pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_2, __pyx_7genexpr__pyx_v_a); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_10);
__pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_float); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_10, __pyx_n_s_dtype, __pyx_t_14) < 0) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_1, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 80, __pyx_L7_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
</pre><pre class="cython line score-112" onclick='toggleDiv(this)'>+<span class="">081</span>: <span class="k">for</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">,</span> <span class="n">conds_keys</span><span class="p">)]))</span></pre>
<pre class='cython code score-112 '> <span class='trace'>__Pyx_TraceLine</span>(81,0,__PYX_ERR(0, 81, __pyx_L7_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_conds_keys);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_conds_keys);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1, __pyx_v_conds_keys);
__pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_zip, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_2)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_2)) {
__pyx_t_7 = __pyx_t_2; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_8 = -1; __pyx_t_7 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L7_error)
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_7))) {
if (__pyx_t_8 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_7)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_7, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 81, __pyx_L7_error)
#else
__pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
#endif
} else {
if (__pyx_t_8 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_7)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_7, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 81, __pyx_L7_error)
#else
__pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
#endif
}
} else {
__pyx_t_2 = __pyx_t_9(__pyx_t_7);
if (unlikely(!__pyx_t_2)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 81, __pyx_L7_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
}
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_2))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(2);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 81, __pyx_L7_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_10 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
} else {
__pyx_t_10 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
#else
__pyx_t_10 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_12 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 81, __pyx_L7_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L10_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L10_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 81, __pyx_L7_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
goto __pyx_L11_unpacking_done;
__pyx_L10_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 81, __pyx_L7_error)
__pyx_L11_unpacking_done:;
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_7genexpr__pyx_v_a, __pyx_t_10);
__pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_7genexpr__pyx_v_b, __pyx_t_11);
__pyx_t_11 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(81,0,__PYX_ERR(0, 81, __pyx_L7_error))
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_7genexpr__pyx_v_a);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_7genexpr__pyx_v_b);
goto __pyx_L12_exit_scope;
__pyx_L7_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_7genexpr__pyx_v_a);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_7genexpr__pyx_v_b);
goto __pyx_L1_error;
__pyx_L12_exit_scope:;
} /* exit inner scope */
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">082</span>: <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">cur_conds</span><span class="p">)</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(82,0,__PYX_ERR(0, 82, __pyx_L1_error))
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_cur_conds); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 82, __pyx_L1_error)
__pyx_t_6 = ((__pyx_t_8 == 0) != 0);
if (__pyx_t_6) {
/* … */
}
</pre><pre class="cython line score-9" onclick='toggleDiv(this)'>+<span class="">083</span>: <span class="n">cur_conds</span> <span class="o">=</span> <span class="n">properties</span><span class="p">[</span><span class="s">'GM'</span><span class="p">]</span><span class="o">.</span><span class="n">coords</span></pre>
<pre class='cython code score-9 '> <span class='trace'>__Pyx_TraceLine</span>(83,0,__PYX_ERR(0, 83, __pyx_L1_error))
__pyx_t_4 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_properties, __pyx_n_u_GM); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_coords); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_cur_conds, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-0"> <span class="">084</span>: <span class="c"># sum of independently specified components</span></pre>
<pre class="cython line score-91" onclick='toggleDiv(this)'>+<span class="">085</span>: <span class="n">indep_sum</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">cur_conds</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'X_'</span><span class="p">)])</span></pre>
<pre class='cython code score-91 '> <span class='trace'>__Pyx_TraceLine</span>(85,0,__PYX_ERR(0, 85, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
{ /* enter inner scope */
PyObject *__pyx_8genexpr1__pyx_v_i = NULL;
PyObject *__pyx_8genexpr1__pyx_v_val = NULL;
__pyx_t_4 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_8 = 0;
if (unlikely(__pyx_v_cur_conds == Py_None)) {
<span class='py_c_api'>PyErr_Format</span>(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items");
__PYX_ERR(0, 85, __pyx_L16_error)
}
__pyx_t_7 = __Pyx_dict_iterator(__pyx_v_cur_conds, 0, __pyx_n_s_items, (&__pyx_t_15), (&__pyx_t_16)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1);
__pyx_t_1 = __pyx_t_7;
__pyx_t_7 = 0;
while (1) {
__pyx_t_17 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_15, &__pyx_t_8, &__pyx_t_7, &__pyx_t_10, NULL, __pyx_t_16);
if (unlikely(__pyx_t_17 == 0)) break;
if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr1__pyx_v_i, __pyx_t_7);
__pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr1__pyx_v_val, __pyx_t_10);
__pyx_t_10 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_8genexpr1__pyx_v_i, __pyx_n_s_startswith); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_10, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_7); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
if (__pyx_t_6) {
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyNumber_Float</span>(__pyx_8genexpr1__pyx_v_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_4, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 85, __pyx_L16_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr1__pyx_v_i);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr1__pyx_v_val);
goto __pyx_L20_exit_scope;
__pyx_L16_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr1__pyx_v_i);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr1__pyx_v_val);
goto __pyx_L1_error;
__pyx_L20_exit_scope:;
} /* exit inner scope */
__pyx_t_1 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_1 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_1)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
}
}
if (!__pyx_t_1) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_14, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
} else
#endif
{
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+1, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_18 = __pyx_<span class='py_c_api'>PyFloat_AsDouble</span>(__pyx_t_3); if (unlikely((__pyx_t_18 == (double)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_indep_sum = __pyx_t_18;
/* … */
__pyx_tuple__2 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_u_X_2); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 85, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__2);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">086</span>: <span class="k">if</span> <span class="n">indep_sum</span> <span class="o">></span> <span class="mf">1</span><span class="p">:</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(86,0,__PYX_ERR(0, 86, __pyx_L1_error))
__pyx_t_6 = ((__pyx_v_indep_sum > 1.0) != 0);
if (__pyx_t_6) {
/* … */
}
</pre><pre class="cython line score-0"> <span class="">087</span>: <span class="c"># Sum of independent component mole fractions greater than one</span></pre>
<pre class="cython line score-0"> <span class="">088</span>: <span class="c"># Skip this condition set</span></pre>
<pre class="cython line score-0"> <span class="">089</span>: <span class="c"># We silently allow this to make 2-D composition mapping easier</span></pre>
<pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">090</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(90,0,__PYX_ERR(0, 90, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 90, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_3, __pyx_t_14) < 0)) __PYX_ERR(0, 90, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
</pre><pre class="cython line score-36" onclick='toggleDiv(this)'>+<span class="">091</span>: <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-36 '> <span class='trace'>__Pyx_TraceLine</span>(91,0,__PYX_ERR(0, 91, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
if (unlikely(!__pyx_v_phases)) { <span class='pyx_c_api'>__Pyx_RaiseUnboundLocalError</span>("phases"); __PYX_ERR(0, 91, __pyx_L1_error) }
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 91, __pyx_L1_error)
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_4, 0, __pyx_t_15, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_14, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_NP_values, __pyx_t_4, __pyx_t_3) < 0)) __PYX_ERR(0, 91, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-30" onclick='toggleDiv(this)'>+<span class="">092</span>: <span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span> <span class="o">=</span> <span class="s">''</span></pre>
<pre class='cython code score-30 '> <span class='trace'>__Pyx_TraceLine</span>(92,0,__PYX_ERR(0, 92, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_v_phases)) { <span class='pyx_c_api'>__Pyx_RaiseUnboundLocalError</span>("phases"); __PYX_ERR(0, 92, __pyx_L1_error) }
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 92, __pyx_L1_error)
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_7, 0, __pyx_t_15, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_7, __pyx_kp_u__3) < 0)) __PYX_ERR(0, 92, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
</pre><pre class="cython line score-36" onclick='toggleDiv(this)'>+<span class="">093</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-36 '> <span class='trace'>__Pyx_TraceLine</span>(93,0,__PYX_ERR(0, 93, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_v_phases)) { <span class='pyx_c_api'>__Pyx_RaiseUnboundLocalError</span>("phases"); __PYX_ERR(0, 93, __pyx_L1_error) }
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 93, __pyx_L1_error)
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_14, 0, __pyx_t_15, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_X_values, __pyx_t_14, __pyx_t_4) < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">094</span>: <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(94,0,__PYX_ERR(0, 94, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 94, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Y_values, __pyx_t_4, __pyx_t_14) < 0)) __PYX_ERR(0, 94, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">095</span>: <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(95,0,__PYX_ERR(0, 95, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 95, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 95, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_GM_values, __pyx_t_14, __pyx_t_4) < 0)) __PYX_ERR(0, 95, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">096</span>: <span class="n">it</span><span class="o">.</span><span class="n">iternext</span><span class="p">()</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(96,0,__PYX_ERR(0, 96, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_iternext); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 96, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
}
}
if (__pyx_t_3) {
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_14, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
} else {
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">097</span>: <span class="k">continue</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(97,0,__PYX_ERR(0, 97, __pyx_L1_error))
goto __pyx_L3_continue;
</pre><pre class="cython line score-74" onclick='toggleDiv(this)'>+<span class="">098</span>: <span class="n">dependent_comp</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">comps</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">([</span><span class="n">i</span><span class="p">[</span><span class="mf">2</span><span class="p">:]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">cur_conds</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'X_'</span><span class="p">)])</span> <span class="o">-</span> <span class="p">{</span><span class="s">'VA'</span><span class="p">}</span></pre>
<pre class='cython code score-74 '> <span class='trace'>__Pyx_TraceLine</span>(98,0,__PYX_ERR(0, 98, __pyx_L1_error))
__pyx_t_4 = <span class='py_c_api'>PySet_New</span>(__pyx_v_comps); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
{ /* enter inner scope */
PyObject *__pyx_8genexpr2__pyx_v_i = NULL;
__pyx_t_14 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_15 = 0;
if (unlikely(__pyx_v_cur_conds == Py_None)) {
<span class='py_c_api'>PyErr_Format</span>(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "keys");
__PYX_ERR(0, 98, __pyx_L24_error)
}
__pyx_t_7 = __Pyx_dict_iterator(__pyx_v_cur_conds, 0, __pyx_n_s_keys, (&__pyx_t_8), (&__pyx_t_16)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3);
__pyx_t_3 = __pyx_t_7;
__pyx_t_7 = 0;
while (1) {
__pyx_t_17 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_8, &__pyx_t_15, &__pyx_t_7, NULL, NULL, __pyx_t_16);
if (unlikely(__pyx_t_17 == 0)) break;
if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr2__pyx_v_i, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_8genexpr2__pyx_v_i, __pyx_n_s_startswith); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_6) {
/* … */
__pyx_tuple__4 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_u_X_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__4);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_8genexpr2__pyx_v_i, 2, 0, NULL, NULL, &__pyx_slice__5, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_14, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 98, __pyx_L24_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr2__pyx_v_i);
goto __pyx_L28_exit_scope;
__pyx_L24_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr2__pyx_v_i);
goto __pyx_L1_error;
__pyx_L28_exit_scope:;
} /* exit inner scope */
__pyx_t_3 = <span class='py_c_api'>PySet_New</span>(__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PySet_New</span>(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (<span class='py_c_api'>PySet_Add</span>(__pyx_t_3, __pyx_n_u_VA) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
__pyx_t_4 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_14, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_dependent_comp, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_slice__5 = <span class='py_c_api'>PySlice_New</span>(__pyx_int_2, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 98, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__5);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__5);
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">099</span>: <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">dependent_comp</span><span class="p">)</span> <span class="o">==</span> <span class="mf">1</span><span class="p">:</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(99,0,__PYX_ERR(0, 99, __pyx_L1_error))
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_dependent_comp); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 99, __pyx_L1_error)
__pyx_t_6 = ((__pyx_t_8 == 1) != 0);
if (__pyx_t_6) {
/* … */
goto __pyx_L29;
}
</pre><pre class="cython line score-9" onclick='toggleDiv(this)'>+<span class="">100</span>: <span class="n">dependent_comp</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">dependent_comp</span><span class="p">)[</span><span class="mf">0</span><span class="p">]</span></pre>
<pre class='cython code score-9 '> <span class='trace'>__Pyx_TraceLine</span>(100,0,__PYX_ERR(0, 100, __pyx_L1_error))
__pyx_t_4 = <span class='py_c_api'>PySequence_List</span>(__pyx_v_dependent_comp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetItemInt_List</span>(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_dependent_comp, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-0"> <span class="">101</span>: <span class="k">else</span><span class="p">:</span></pre>
<pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">102</span>: <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">'Number of dependent components different from one'</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(102,0,__PYX_ERR(0, 102, __pyx_L1_error))
/*else*/ {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_3, 0, 0, 0);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(0, 102, __pyx_L1_error)
}
__pyx_L29:;
/* … */
__pyx_tuple__6 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Number_of_dependent_components_d); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 102, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__6);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__6);
</pre><pre class="cython line score-0"> <span class="">103</span>: <span class="c"># chem_pots = OrderedDict(zip(properties.coords['component'].values, properties['MU'].values[it.multi_index]))</span></pre>
<pre class="cython line score-0"> <span class="">104</span>: <span class="c"># Used to cache generated mole fraction functions</span></pre>
<pre class="cython line score-6" onclick='toggleDiv(this)'>+<span class="">105</span>: <span class="n">mole_fractions</span> <span class="o">=</span> <span class="p">{}</span></pre>
<pre class='cython code score-6 '> <span class='trace'>__Pyx_TraceLine</span>(105,0,__PYX_ERR(0, 105, __pyx_L1_error))
__pyx_t_3 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_mole_fractions, ((PyObject*)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">106</span>: <span class="k">for</span> <span class="n">cur_iter</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">MAX_SOLVE_ITERATIONS</span><span class="p">):</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(106,0,__PYX_ERR(0, 106, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_SOLVE_ITERATIONS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_19 = <span class='pyx_c_api'>__Pyx_PyInt_As_long</span>(__pyx_t_3); if (unlikely((__pyx_t_19 == (long)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 106, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_19; __pyx_t_16+=1) {
__pyx_v_cur_iter = __pyx_t_16;
</pre><pre class="cython line score-0"> <span class="">107</span>: <span class="c"># print('CUR_ITER:', cur_iter)</span></pre>
<pre class="cython line score-15" onclick='toggleDiv(this)'>+<span class="">108</span>: <span class="n">phases</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">])</span></pre>
<pre class='cython code score-15 '> <span class='trace'>__Pyx_TraceLine</span>(108,0,__PYX_ERR(0, 108, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PySequence_List</span>(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_phases, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">109</span>: <span class="k">if</span> <span class="s">''</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(109,0,__PYX_ERR(0, 109, __pyx_L1_error))
__pyx_t_6 = (<span class='pyx_c_api'>__Pyx_PySequence_ContainsTF</span>(__pyx_kp_u__3, __pyx_v_phases, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 109, __pyx_L1_error)
__pyx_t_5 = (__pyx_t_6 != 0);
if (__pyx_t_5) {
/* … */
goto __pyx_L32;
}
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">110</span>: <span class="n">old_phase_length</span> <span class="o">=</span> <span class="n">phases</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s">''</span><span class="p">)</span></pre>
<pre class='cython code score-18 '> <span class='trace'>__Pyx_TraceLine</span>(110,0,__PYX_ERR(0, 110, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_phases, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_4); if (unlikely((__pyx_t_17 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 110, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_old_phase_length = __pyx_t_17;
/* … */
__pyx_tuple__7 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u__3); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 110, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__7);
</pre><pre class="cython line score-0"> <span class="">111</span>: <span class="k">else</span><span class="p">:</span></pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">112</span>: <span class="n">old_phase_length</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(112,0,__PYX_ERR(0, 112, __pyx_L1_error))
/*else*/ {
__pyx_v_old_phase_length = -1;
}
__pyx_L32:;
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">113</span>: <span class="n">remove_degenerate_phases</span><span class="p">(</span><span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">],</span> <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">],</span></pre>
<pre class='cython code score-18 '> <span class='trace'>__Pyx_TraceLine</span>(113,0,__PYX_ERR(0, 113, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_remove_degenerate_phases); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_1 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_7 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_X_values, __pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
</pre><pre class="cython line score-62" onclick='toggleDiv(this)'>+<span class="">114</span>: <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">],</span> <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">])</span></pre>
<pre class='cython code score-62 '> <span class='trace'>__Pyx_TraceLine</span>(114,0,__PYX_ERR(0, 114, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 114, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_10 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Y_values, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 114, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 114, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_NP_values, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[5] = {__pyx_t_14, __pyx_t_1, __pyx_t_7, __pyx_t_10, __pyx_t_2};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[5] = {__pyx_t_14, __pyx_t_1, __pyx_t_7, __pyx_t_10, __pyx_t_2};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 4+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
{
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(4+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (__pyx_t_14) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_14); __pyx_t_14 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0+__pyx_t_17, __pyx_t_1);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1+__pyx_t_17, __pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 2+__pyx_t_17, __pyx_t_10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 3+__pyx_t_17, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_7 = 0;
__pyx_t_10 = 0;
__pyx_t_2 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
</pre><pre class="cython line score-15" onclick='toggleDiv(this)'>+<span class="">115</span>: <span class="n">phases</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">])</span></pre>
<pre class='cython code score-15 '> <span class='trace'>__Pyx_TraceLine</span>(115,0,__PYX_ERR(0, 115, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PySequence_List</span>(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_phases, __pyx_t_4);
__pyx_t_4 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">116</span>: <span class="k">if</span> <span class="s">''</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(116,0,__PYX_ERR(0, 116, __pyx_L1_error))
__pyx_t_5 = (<span class='pyx_c_api'>__Pyx_PySequence_ContainsTF</span>(__pyx_kp_u__3, __pyx_v_phases, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 116, __pyx_L1_error)
__pyx_t_6 = (__pyx_t_5 != 0);
if (__pyx_t_6) {
/* … */
goto __pyx_L33;
}
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">117</span>: <span class="n">new_phase_length</span> <span class="o">=</span> <span class="n">phases</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s">''</span><span class="p">)</span></pre>
<pre class='cython code score-18 '> <span class='trace'>__Pyx_TraceLine</span>(117,0,__PYX_ERR(0, 117, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_phases, __pyx_n_s_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_3); if (unlikely((__pyx_t_17 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 117, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_new_phase_length = __pyx_t_17;
/* … */
__pyx_tuple__8 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u__3); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 117, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__8);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__8);
</pre><pre class="cython line score-0"> <span class="">118</span>: <span class="k">else</span><span class="p">:</span></pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">119</span>: <span class="n">new_phase_length</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(119,0,__PYX_ERR(0, 119, __pyx_L1_error))
/*else*/ {
__pyx_v_new_phase_length = -1;
}
__pyx_L33:;
</pre><pre class="cython line score-0"> <span class="">120</span>: <span class="c"># Are there removed phases?</span></pre>
<pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">121</span>: <span class="k">if</span> <span class="s">''</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(121,0,__PYX_ERR(0, 121, __pyx_L1_error))
__pyx_t_6 = (<span class='pyx_c_api'>__Pyx_PySequence_ContainsTF</span>(__pyx_kp_u__3, __pyx_v_phases, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 121, __pyx_L1_error)
__pyx_t_5 = (__pyx_t_6 != 0);
if (__pyx_t_5) {
/* … */
goto __pyx_L34;
}
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">122</span>: <span class="n">num_phases</span> <span class="o">=</span> <span class="n">phases</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s">''</span><span class="p">)</span></pre>
<pre class='cython code score-18 '> <span class='trace'>__Pyx_TraceLine</span>(122,0,__PYX_ERR(0, 122, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_phases, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 122, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_t_4); if (unlikely((__pyx_t_17 == (int)-1) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 122, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_num_phases = __pyx_t_17;
/* … */
__pyx_tuple__9 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u__3); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 122, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__9);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__9);
</pre><pre class="cython line score-0"> <span class="">123</span>: <span class="k">else</span><span class="p">:</span></pre>
<pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">124</span>: <span class="n">num_phases</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(124,0,__PYX_ERR(0, 124, __pyx_L1_error))
/*else*/ {
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 124, __pyx_L1_error)
__pyx_v_num_phases = __pyx_t_8;
}
__pyx_L34:;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">125</span>: <span class="k">if</span> <span class="n">num_phases</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(125,0,__PYX_ERR(0, 125, __pyx_L1_error))
__pyx_t_5 = ((__pyx_v_num_phases == 0) != 0);
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">126</span>: <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">'Zero phases are left in the system'</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(126,0,__PYX_ERR(0, 126, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_4, 0, 0, 0);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__PYX_ERR(0, 126, __pyx_L1_error)
/* … */
__pyx_tuple__10 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Zero_phases_are_left_in_the_syst); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 126, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__10);
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">127</span>: <span class="n">zero_dof</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(127,0,__PYX_ERR(0, 127, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_all); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-110" onclick='toggleDiv(this)'>+<span class="">128</span>: <span class="p">(</span><span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">==</span> <span class="mf">1.</span><span class="p">)</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]))</span></pre>
<pre class='cython code score-110 '> <span class='trace'>__Pyx_TraceLine</span>(128,0,__PYX_ERR(0, 128, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Y_values, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFloat_EqObjC</span>(__pyx_t_2, __pyx_float_1_, 1., 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_10, __pyx_n_s_isnan); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_1 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Y_values, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
__pyx_t_10 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
if (likely(__pyx_t_10)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
}
}
if (!__pyx_t_10) {
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_1};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
{
__pyx_t_14 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0, __pyx_t_10); __pyx_t_10 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0+1, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='py_c_api'>PyNumber_Or</span>(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 128, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_2) {
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_7};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_7};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+1, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_zero_dof, __pyx_t_4);
__pyx_t_4 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">129</span>: <span class="k">if</span> <span class="p">(</span><span class="n">num_phases</span> <span class="o">==</span> <span class="mf">1</span><span class="p">)</span> <span class="ow">and</span> <span class="n">zero_dof</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(129,0,__PYX_ERR(0, 129, __pyx_L1_error))
__pyx_t_6 = ((__pyx_v_num_phases == 1) != 0);
if (__pyx_t_6) {
} else {
__pyx_t_5 = __pyx_t_6;
goto __pyx_L37_bool_binop_done;
}
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_zero_dof); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 129, __pyx_L1_error)
__pyx_t_5 = __pyx_t_6;
__pyx_L37_bool_binop_done:;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-0"> <span class="">130</span>: <span class="c"># Single phase with zero internal degrees of freedom, can't do any refinement</span></pre>
<pre class="cython line score-0"> <span class="">131</span>: <span class="c"># TODO: In the future we may be able to refine other degrees of freedom like temperature</span></pre>
<pre class="cython line score-0"> <span class="">132</span>: <span class="c"># Chemical potentials have no meaning for this case</span></pre>
<pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">133</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(133,0,__PYX_ERR(0, 133, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 133, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_4, __pyx_t_11) < 0)) __PYX_ERR(0, 133, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">134</span>: <span class="k">break</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(134,0,__PYX_ERR(0, 134, __pyx_L1_error))
goto __pyx_L31_break;
</pre><pre class="cython line score-24" onclick='toggleDiv(this)'>+<span class="">135</span>: <span class="n">phases</span> <span class="o">=</span> <span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="n">num_phases</span><span class="p">]]</span></pre>
<pre class='cython code score-24 '> <span class='trace'>__Pyx_TraceLine</span>(135,0,__PYX_ERR(0, 135, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_3, 0, __pyx_v_num_phases, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_phases, __pyx_t_4);
__pyx_t_4 = 0;
</pre><pre class="cython line score-0"> <span class="">136</span>: <span class="c"># num_sitefrac_bals = sum([len(dbf.phases[i].sublattices) for i in phases])</span></pre>
<pre class="cython line score-0"> <span class="">137</span>: <span class="c"># num_mass_bals = len([i for i in cur_conds.keys() if i.startswith('X_')]) + 1</span></pre>
<pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">138</span>: <span class="n">phase_fracs</span> <span class="o">=</span> <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span></pre>
<pre class='cython code score-49 '> <span class='trace'>__Pyx_TraceLine</span>(138,0,__PYX_ERR(0, 138, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 138, __pyx_L1_error)
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_11, 0, __pyx_t_8, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_NP_values, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 138, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_v_phase_fracs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_phase_fracs.diminfo[0].strides = __pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_phase_fracs.diminfo[0].shape = __pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 138, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_phase_fracs, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-116" onclick='toggleDiv(this)'>+<span class="">139</span>: <span class="n">phase_dof</span> <span class="o">=</span> <span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">phase_records</span><span class="p">[</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">variables</span><span class="p">)</span> <span class="o">-</span> <span class="p">{</span><span class="n">v</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">v</span><span class="o">.</span><span class="n">P</span><span class="p">})</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">]</span></pre>
<pre class='cython code score-116 '> <span class='trace'>__Pyx_TraceLine</span>(139,0,__PYX_ERR(0, 139, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr3__pyx_v_name = NULL;
__pyx_t_3 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_11 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_8 = -1; __pyx_t_11 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_9 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 139, __pyx_L41_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
if (__pyx_t_8 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_11, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 139, __pyx_L41_error)
#else
__pyx_t_4 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
#endif
} else {
if (__pyx_t_8 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_11, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 139, __pyx_L41_error)
#else
__pyx_t_4 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_9(__pyx_t_11);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 139, __pyx_L41_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr3__pyx_v_name, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_phase_records, __pyx_8genexpr3__pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_variables); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PySet_New</span>(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_P); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='py_c_api'>PySet_New</span>(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (<span class='py_c_api'>PySet_Add</span>(__pyx_t_7, __pyx_t_2) < 0) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if (<span class='py_c_api'>PySet_Add</span>(__pyx_t_7, __pyx_t_14) < 0) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_14); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_3, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 139, __pyx_L41_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr3__pyx_v_name);
goto __pyx_L44_exit_scope;
__pyx_L41_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr3__pyx_v_name);
goto __pyx_L1_error;
__pyx_L44_exit_scope:;
} /* exit inner scope */
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_phase_dof, ((PyObject*)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-0"> <span class="">140</span>: <span class="c"># Flatten site fractions array and remove nan padding</span></pre>
<pre class="cython line score-48" onclick='toggleDiv(this)'>+<span class="">141</span>: <span class="n">site_fracs</span> <span class="o">=</span> <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span><span class="o">.</span><span class="n">ravel</span><span class="p">()</span></pre>
<pre class='cython code score-48 '> <span class='trace'>__Pyx_TraceLine</span>(141,0,__PYX_ERR(0, 141, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 141, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_14 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_Y_values, __pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 141, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_ravel); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 141, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (__pyx_t_14) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 141, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_fracs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_site_fracs.diminfo[0].strides = __pyx_pybuffernd_site_fracs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_site_fracs.diminfo[0].shape = __pyx_pybuffernd_site_fracs.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 141, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_site_fracs, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-0"> <span class="">142</span>: <span class="c"># That *should* give us the internal dof</span></pre>
<pre class="cython line score-0"> <span class="">143</span>: <span class="c"># This may break if non-padding nan's slipped in from elsewhere...</span></pre>
<pre class="cython line score-75" onclick='toggleDiv(this)'>+<span class="">144</span>: <span class="n">site_fracs</span> <span class="o">=</span> <span class="n">site_fracs</span><span class="p">[</span><span class="o">~</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">)]</span></pre>
<pre class='cython code score-75 '> <span class='trace'>__Pyx_TraceLine</span>(144,0,__PYX_ERR(0, 144, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_isnan); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_11 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_11)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
}
}
if (!__pyx_t_11) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_14, ((PyObject *)__pyx_v_site_fracs)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_site_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_site_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
{
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_11); __pyx_t_11 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+1, ((PyObject *)__pyx_v_site_fracs));
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyNumber_Invert</span>(__pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(((PyObject *)__pyx_v_site_fracs), __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 144, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_fracs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_site_fracs.diminfo[0].strides = __pyx_pybuffernd_site_fracs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_site_fracs.diminfo[0].shape = __pyx_pybuffernd_site_fracs.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 144, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_site_fracs, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-17" onclick='toggleDiv(this)'>+<span class="">145</span>: <span class="n">site_fracs</span><span class="p">[</span><span class="n">site_fracs</span> <span class="o"><</span> <span class="n">MIN_SITE_FRACTION</span><span class="p">]</span> <span class="o">=</span> <span class="n">MIN_SITE_FRACTION</span></pre>
<pre class='cython code score-17 '> <span class='trace'>__Pyx_TraceLine</span>(145,0,__PYX_ERR(0, 145, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 145, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_7 = <span class='py_c_api'>PyObject_RichCompare</span>(((PyObject *)__pyx_v_site_fracs), __pyx_t_14, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 145, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(((PyObject *)__pyx_v_site_fracs), __pyx_t_7, __pyx_t_3) < 0)) __PYX_ERR(0, 145, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">146</span>: <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">)</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(146,0,__PYX_ERR(0, 146, __pyx_L1_error))
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(((PyObject *)__pyx_v_site_fracs)); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 146, __pyx_L1_error)
__pyx_t_5 = ((__pyx_t_8 == 0) != 0);
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-11" onclick='toggleDiv(this)'>+<span class="">147</span>: <span class="k">print</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span></pre>
<pre class='cython code score-11 '> <span class='trace'>__Pyx_TraceLine</span>(147,0,__PYX_ERR(0, 147, __pyx_L1_error))
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_properties);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_properties);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_v_properties);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">148</span>: <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">'Site fractions are invalid'</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(148,0,__PYX_ERR(0, 148, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_7, 0, 0, 0);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__PYX_ERR(0, 148, __pyx_L1_error)
/* … */
__pyx_tuple__11 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Site_fractions_are_invalid); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 148, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__11);
</pre><pre class="cython line score-17" onclick='toggleDiv(this)'>+<span class="">149</span>: <span class="n">phase_fracs</span><span class="p">[</span><span class="n">phase_fracs</span> <span class="o"><</span> <span class="n">MIN_SITE_FRACTION</span><span class="p">]</span> <span class="o">=</span> <span class="n">MIN_SITE_FRACTION</span></pre>
<pre class='cython code score-17 '> <span class='trace'>__Pyx_TraceLine</span>(149,0,__PYX_ERR(0, 149, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 149, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_14 = <span class='py_c_api'>PyObject_RichCompare</span>(((PyObject *)__pyx_v_phase_fracs), __pyx_t_3, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 149, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(((PyObject *)__pyx_v_phase_fracs), __pyx_t_14, __pyx_t_7) < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">150</span>: <span class="n">var_idx</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(150,0,__PYX_ERR(0, 150, __pyx_L1_error))
__pyx_v_var_idx = 0;
</pre><pre class="cython line score-46" onclick='toggleDiv(this)'>+<span class="">151</span>: <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">:</span></pre>
<pre class='cython code score-46 '> <span class='trace'>__Pyx_TraceLine</span>(151,0,__PYX_ERR(0, 151, __pyx_L1_error))
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_7 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_8 = -1; __pyx_t_7 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 151, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_7))) {
if (__pyx_t_8 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_7)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_14 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_7, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 151, __pyx_L1_error)
#else
__pyx_t_14 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 151, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
#endif
} else {
if (__pyx_t_8 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_7)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_14 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_7, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 151, __pyx_L1_error)
#else
__pyx_t_14 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 151, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
#endif
}
} else {
__pyx_t_14 = __pyx_t_9(__pyx_t_7);
if (unlikely(!__pyx_t_14)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 151, __pyx_L1_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_name, __pyx_t_14);
__pyx_t_14 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(151,0,__PYX_ERR(0, 151, __pyx_L1_error))
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
</pre><pre class="cython line score-17" onclick='toggleDiv(this)'>+<span class="">152</span>: <span class="k">for</span> <span class="n">idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">sublattices</span><span class="p">)):</span></pre>
<pre class='cython code score-17 '> <span class='trace'>__Pyx_TraceLine</span>(152,0,__PYX_ERR(0, 152, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 152, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_14, __pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 152, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_sublattices); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 152, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_14); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 152, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_15; __pyx_t_24+=1) {
__pyx_v_idx = __pyx_t_24;
</pre><pre class="cython line score-61" onclick='toggleDiv(this)'>+<span class="">153</span>: <span class="n">active_in_subl</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">constituents</span><span class="p">[</span><span class="n">idx</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">comps</span><span class="p">)</span></pre>
<pre class='cython code score-61 '> <span class='trace'>__Pyx_TraceLine</span>(153,0,__PYX_ERR(0, 153, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_3, __pyx_v_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_constituents); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetItemInt</span>(__pyx_t_3, __pyx_v_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PySet_New</span>(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_intersection); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_3) {
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_v_comps); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_comps};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_comps};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else
#endif
{
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comps);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comps);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0+1, __pyx_v_comps);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_4, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 153, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_active_in_subl, __pyx_t_14);
__pyx_t_14 = 0;
</pre><pre class="cython line score-66" onclick='toggleDiv(this)'>+<span class="">154</span>: <span class="k">for</span> <span class="n">ais</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">active_in_subl</span><span class="p">)):</span></pre>
<pre class='cython code score-66 '> <span class='trace'>__Pyx_TraceLine</span>(154,0,__PYX_ERR(0, 154, __pyx_L1_error))
__pyx_t_25 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_active_in_subl); if (unlikely(__pyx_t_25 == -1)) __PYX_ERR(0, 154, __pyx_L1_error)
__pyx_t_14 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_25); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_14);
__pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_range, __pyx_t_11, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_14)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_14)) {
__pyx_t_11 = __pyx_t_14; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_25 = 0;
__pyx_t_26 = NULL;
} else {
__pyx_t_25 = -1; __pyx_t_11 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_26 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 154, __pyx_L1_error)
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
for (;;) {
if (likely(!__pyx_t_26)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
if (__pyx_t_25 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_14 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_11, __pyx_t_25); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14); __pyx_t_25++; if (unlikely(0 < 0)) __PYX_ERR(0, 154, __pyx_L1_error)
#else
__pyx_t_14 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_25); __pyx_t_25++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
#endif
} else {
if (__pyx_t_25 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_14 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_11, __pyx_t_25); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14); __pyx_t_25++; if (unlikely(0 < 0)) __PYX_ERR(0, 154, __pyx_L1_error)
#else
__pyx_t_14 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_25); __pyx_t_25++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 154, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
#endif
}
} else {
__pyx_t_14 = __pyx_t_26(__pyx_t_11);
if (unlikely(!__pyx_t_14)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 154, __pyx_L1_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_ais, __pyx_t_14);
__pyx_t_14 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(154,0,__PYX_ERR(0, 154, __pyx_L1_error))
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">155</span>: <span class="n">site_fracs</span><span class="p">[</span><span class="n">var_idx</span> <span class="o">+</span> <span class="n">ais</span><span class="p">]</span> <span class="o">=</span> <span class="n">site_fracs</span><span class="p">[</span><span class="n">var_idx</span> <span class="o">+</span> <span class="n">ais</span><span class="p">]</span> <span class="o">/</span> <span class="nb">sum</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">[</span><span class="n">var_idx</span><span class="p">:</span><span class="n">var_idx</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">active_in_subl</span><span class="p">)])</span></pre>
<pre class='cython code score-49 '> <span class='trace'>__Pyx_TraceLine</span>(155,0,__PYX_ERR(0, 155, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_var_idx); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_4 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_14, __pyx_v_ais); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyObject_GetItem</span>(((PyObject *)__pyx_v_site_fracs), __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_27 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_active_in_subl); if (unlikely(__pyx_t_27 == -1)) __PYX_ERR(0, 155, __pyx_L1_error)
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(((PyObject *)__pyx_v_site_fracs), __pyx_v_var_idx, (__pyx_v_var_idx + __pyx_t_27), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_sum, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyNumber_Divide</span>(__pyx_t_14, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_var_idx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_14 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_4, __pyx_v_ais); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(((PyObject *)__pyx_v_site_fracs), __pyx_t_14, __pyx_t_3) < 0)) __PYX_ERR(0, 155, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">156</span>: <span class="n">var_idx</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">active_in_subl</span><span class="p">)</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(156,0,__PYX_ERR(0, 156, __pyx_L1_error))
__pyx_t_25 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_active_in_subl); if (unlikely(__pyx_t_25 == -1)) __PYX_ERR(0, 156, __pyx_L1_error)
__pyx_v_var_idx = (__pyx_v_var_idx + __pyx_t_25);
}
</pre><pre class="cython line score-43" onclick='toggleDiv(this)'>+<span class="">157</span>: <span class="n">l_constraints</span><span class="p">,</span> <span class="n">constraint_jac</span><span class="p">,</span> <span class="n">constraint_hess</span> <span class="o">=</span> \</pre>
<pre class='cython code score-43 '> <span class='trace'>__Pyx_TraceLine</span>(157,0,__PYX_ERR(0, 157, __pyx_L1_error))
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
if (!(likely(((__pyx_t_11) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
__pyx_t_28 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_constraints.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_constraints.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_constraints.rcbuffer->pybuffer, (PyObject*)__pyx_v_l_constraints, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_l_constraints.diminfo[0].strides = __pyx_pybuffernd_l_constraints.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_l_constraints.diminfo[0].shape = __pyx_pybuffernd_l_constraints.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
}
__pyx_t_28 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_l_constraints, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
__pyx_t_29 = ((PyArrayObject *)__pyx_t_11);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer, (PyObject*)__pyx_v_constraint_jac, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_constraint_jac.diminfo[0].strides = __pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_constraint_jac.diminfo[0].shape = __pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_constraint_jac.diminfo[1].strides = __pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_constraint_jac.diminfo[1].shape = __pyx_pybuffernd_constraint_jac.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_constraint_jac, ((PyArrayObject *)__pyx_t_11));
__pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_constraint_hess, __pyx_t_7);
__pyx_t_7 = 0;
</pre><pre class="cython line score-87" onclick='toggleDiv(this)'>+<span class="">158</span>: <span class="n">_compute_constraints</span><span class="p">(</span><span class="n">dbf</span><span class="p">,</span> <span class="n">comps</span><span class="p">,</span> <span class="n">phases</span><span class="p">,</span> <span class="n">cur_conds</span><span class="p">,</span> <span class="n">site_fracs</span><span class="p">,</span> <span class="n">phase_fracs</span><span class="p">,</span> <span class="n">phase_records</span><span class="p">,</span> <span class="n">mole_fractions</span><span class="o">=</span><span class="n">mole_fractions</span><span class="p">)</span></pre>
<pre class='cython code score-87 '> <span class='trace'>__Pyx_TraceLine</span>(158,0,__PYX_ERR(0, 158, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_compute_constraints); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 158, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_dbf);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_dbf);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_v_dbf);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comps);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comps);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1, __pyx_v_comps);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phases);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 2, __pyx_v_phases);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 3, __pyx_v_cur_conds);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 4, ((PyObject *)__pyx_v_site_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 5, ((PyObject *)__pyx_v_phase_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phase_records);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phase_records);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 6, __pyx_v_phase_records);
__pyx_t_3 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_3, __pyx_n_s_mole_fractions, __pyx_v_mole_fractions) < 0) __PYX_ERR(0, 158, __pyx_L1_error)
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 158, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_14))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_14))) {
PyObject* sequence = __pyx_t_14;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 3)) {
if (size > 3) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(3);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 157, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_3 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
__pyx_t_7 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 2);
} else {
__pyx_t_3 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
__pyx_t_7 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 2);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
#else
__pyx_t_3 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_7 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 157, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_4 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext;
index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L52_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_11)) goto __pyx_L52_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
index = 2; __pyx_t_7 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_7)) goto __pyx_L52_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_4), 3) < 0) __PYX_ERR(0, 157, __pyx_L1_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
goto __pyx_L53_unpacking_done;
__pyx_L52_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 157, __pyx_L1_error)
__pyx_L53_unpacking_done:;
}
</pre><pre class="cython line score-0"> <span class="">159</span>: <span class="c"># Reset Lagrange multipliers if active set of phases change</span></pre>
<pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">160</span>: <span class="k">if</span> <span class="n">cur_iter</span> <span class="o">==</span> <span class="mf">0</span> <span class="ow">or</span> <span class="p">(</span><span class="n">old_phase_length</span> <span class="o">!=</span> <span class="n">new_phase_length</span><span class="p">)</span> <span class="ow">or</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">l_multipliers</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(160,0,__PYX_ERR(0, 160, __pyx_L1_error))
__pyx_t_6 = ((__pyx_v_cur_iter == 0) != 0);
if (!__pyx_t_6) {
} else {
__pyx_t_5 = __pyx_t_6;
goto __pyx_L55_bool_binop_done;
}
__pyx_t_6 = ((__pyx_v_old_phase_length != __pyx_v_new_phase_length) != 0);
if (!__pyx_t_6) {
} else {
__pyx_t_5 = __pyx_t_6;
goto __pyx_L55_bool_binop_done;
}
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_any); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_isnan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function);
}
}
if (!__pyx_t_3) {
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_4, ((PyObject *)__pyx_v_l_multipliers)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_multipliers)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_multipliers)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, ((PyObject *)__pyx_v_l_multipliers));
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_4)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_4) {
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_7};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_7};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_14); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_5 = __pyx_t_6;
__pyx_L55_bool_binop_done:;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-67" onclick='toggleDiv(this)'>+<span class="">161</span>: <span class="n">l_multipliers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">l_constraints</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span></pre>
<pre class='cython code score-67 '> <span class='trace'>__Pyx_TraceLine</span>(161,0,__PYX_ERR(0, 161, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyInt_From_Py_intptr_t</span>((__pyx_v_l_constraints->dimensions[0])); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
}
}
if (!__pyx_t_7) {
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, __pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_11};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_11};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
{
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0+1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 161, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if (!(likely(((__pyx_t_14) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_14, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 161, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_14);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_l_multipliers.diminfo[0].strides = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_l_multipliers.diminfo[0].shape = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 161, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_l_multipliers, ((PyArrayObject *)__pyx_t_14));
__pyx_t_14 = 0;
</pre><pre class="cython line score-120" onclick='toggleDiv(this)'>+<span class="">162</span>: <span class="n">qmat</span><span class="p">,</span> <span class="n">rmat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">qr</span><span class="p">(</span><span class="n">constraint_jac</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s">'complete'</span><span class="p">)</span></pre>
<pre class='cython code score-120 '> <span class='trace'>__Pyx_TraceLine</span>(162,0,__PYX_ERR(0, 162, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_linalg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_qr); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_constraint_jac), __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_2, __pyx_n_s_mode, __pyx_n_u_complete) < 0) __PYX_ERR(0, 162, __pyx_L1_error)
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_11))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
PyObject* sequence = __pyx_t_11;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(2);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 162, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_2 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_4 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
} else {
__pyx_t_2 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_4 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
#else
__pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_4 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_14 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 162, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_14)->tp_iternext;
index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_14); if (unlikely(!__pyx_t_2)) goto __pyx_L58_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
index = 1; __pyx_t_4 = __pyx_t_13(__pyx_t_14); if (unlikely(!__pyx_t_4)) goto __pyx_L58_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_14), 2) < 0) __PYX_ERR(0, 162, __pyx_L1_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
goto __pyx_L59_unpacking_done;
__pyx_L58_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 162, __pyx_L1_error)
__pyx_L59_unpacking_done:;
}
if (!(likely(((__pyx_t_2) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 162, __pyx_L1_error)
if (!(likely(((__pyx_t_4) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 162, __pyx_L1_error)
__pyx_t_29 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_qmat.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_qmat.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_qmat.rcbuffer->pybuffer, (PyObject*)__pyx_v_qmat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_qmat.diminfo[0].strides = __pyx_pybuffernd_qmat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_qmat.diminfo[0].shape = __pyx_pybuffernd_qmat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_qmat.diminfo[1].strides = __pyx_pybuffernd_qmat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_qmat.diminfo[1].shape = __pyx_pybuffernd_qmat.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 162, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_qmat, ((PyArrayObject *)__pyx_t_2));
__pyx_t_2 = 0;
__pyx_t_29 = ((PyArrayObject *)__pyx_t_4);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_rmat.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_rmat.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_rmat.rcbuffer->pybuffer, (PyObject*)__pyx_v_rmat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_rmat.diminfo[0].strides = __pyx_pybuffernd_rmat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rmat.diminfo[0].shape = __pyx_pybuffernd_rmat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_rmat.diminfo[1].strides = __pyx_pybuffernd_rmat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_rmat.diminfo[1].shape = __pyx_pybuffernd_rmat.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 162, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_rmat, ((PyArrayObject *)__pyx_t_4));
__pyx_t_4 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">163</span>: <span class="n">m</span> <span class="o">=</span> <span class="n">rmat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">1</span><span class="p">]</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(163,0,__PYX_ERR(0, 163, __pyx_L1_error))
__pyx_v_m = (__pyx_v_rmat->dimensions[1]);
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">164</span>: <span class="n">n</span> <span class="o">=</span> <span class="n">qmat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(164,0,__PYX_ERR(0, 164, __pyx_L1_error))
__pyx_v_n = (__pyx_v_qmat->dimensions[0]);
</pre><pre class="cython line score-0"> <span class="">165</span>: <span class="c"># Construct orthonormal basis for the constraints</span></pre>
<pre class="cython line score-48" onclick='toggleDiv(this)'>+<span class="">166</span>: <span class="n">ymat</span> <span class="o">=</span> <span class="n">qmat</span><span class="p">[:,</span> <span class="p">:</span><span class="n">m</span><span class="p">]</span></pre>
<pre class='cython code score-48 '> <span class='trace'>__Pyx_TraceLine</span>(166,0,__PYX_ERR(0, 166, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_m); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_4 = <span class='py_c_api'>PySlice_New</span>(Py_None, __pyx_t_11, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_slice__12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_slice__12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PyObject_GetItem</span>(((PyObject *)__pyx_v_qmat), __pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (!(likely(((__pyx_t_4) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 166, __pyx_L1_error)
__pyx_t_29 = ((PyArrayObject *)__pyx_t_4);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_ymat.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_ymat.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_ymat.rcbuffer->pybuffer, (PyObject*)__pyx_v_ymat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_ymat.diminfo[0].strides = __pyx_pybuffernd_ymat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ymat.diminfo[0].shape = __pyx_pybuffernd_ymat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ymat.diminfo[1].strides = __pyx_pybuffernd_ymat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ymat.diminfo[1].shape = __pyx_pybuffernd_ymat.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 166, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_ymat, ((PyArrayObject *)__pyx_t_4));
__pyx_t_4 = 0;
/* … */
__pyx_slice__12 = <span class='py_c_api'>PySlice_New</span>(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__12)) __PYX_ERR(0, 166, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__12);
</pre><pre class="cython line score-48" onclick='toggleDiv(this)'>+<span class="">167</span>: <span class="n">zmat</span> <span class="o">=</span> <span class="n">qmat</span><span class="p">[:,</span> <span class="n">m</span><span class="p">:]</span></pre>
<pre class='cython code score-48 '> <span class='trace'>__Pyx_TraceLine</span>(167,0,__PYX_ERR(0, 167, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_m); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_11 = <span class='py_c_api'>PySlice_New</span>(__pyx_t_4, Py_None, Py_None); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_slice__13);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__13);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_slice__13);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyObject_GetItem</span>(((PyObject *)__pyx_v_qmat), __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if (!(likely(((__pyx_t_11) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 167, __pyx_L1_error)
__pyx_t_29 = ((PyArrayObject *)__pyx_t_11);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_zmat.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_zmat.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_zmat.rcbuffer->pybuffer, (PyObject*)__pyx_v_zmat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_zmat.diminfo[0].strides = __pyx_pybuffernd_zmat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_zmat.diminfo[0].shape = __pyx_pybuffernd_zmat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_zmat.diminfo[1].strides = __pyx_pybuffernd_zmat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_zmat.diminfo[1].shape = __pyx_pybuffernd_zmat.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 167, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_zmat, ((PyArrayObject *)__pyx_t_11));
__pyx_t_11 = 0;
/* … */
__pyx_slice__13 = <span class='py_c_api'>PySlice_New</span>(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__13)) __PYX_ERR(0, 167, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__13);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__13);
</pre><pre class="cython line score-0"> <span class="">168</span>: <span class="c"># Equation 18.14a in Nocedal and Wright</span></pre>
<pre class="cython line score-115" onclick='toggleDiv(this)'>+<span class="">169</span>: <span class="n">p_y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">solve</span><span class="p">(</span><span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">constraint_jac</span><span class="p">,</span> <span class="n">ymat</span><span class="p">),</span> <span class="n">l_constraints</span><span class="p">)</span></pre>
<pre class='cython code score-115 '> <span class='trace'>__Pyx_TraceLine</span>(169,0,__PYX_ERR(0, 169, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_linalg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_solve); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_constraint_jac), ((PyObject *)__pyx_v_ymat)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_constraint_jac), ((PyObject *)__pyx_v_ymat)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (__pyx_t_14) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_14); __pyx_t_14 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+__pyx_t_17, ((PyObject *)__pyx_v_constraint_jac));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_ymat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_ymat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1+__pyx_t_17, ((PyObject *)__pyx_v_ymat));
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='py_c_api'>PyNumber_Negative</span>(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_7, ((PyObject *)__pyx_v_l_constraints)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_7, ((PyObject *)__pyx_v_l_constraints)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (__pyx_t_2) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+__pyx_t_17, __pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_constraints));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_constraints));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1+__pyx_t_17, ((PyObject *)__pyx_v_l_constraints));
__pyx_t_7 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 169, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if (!(likely(((__pyx_t_11) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 169, __pyx_L1_error)
__pyx_t_28 = ((PyArrayObject *)__pyx_t_11);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_p_y.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_p_y.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_p_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_y, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_p_y.diminfo[0].strides = __pyx_pybuffernd_p_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_y.diminfo[0].shape = __pyx_pybuffernd_p_y.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 169, __pyx_L1_error)
}
__pyx_t_28 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_p_y, ((PyArrayObject *)__pyx_t_11));
__pyx_t_11 = 0;
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">170</span>: <span class="n">num_vars</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(170,0,__PYX_ERR(0, 170, __pyx_L1_error))
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(((PyObject *)__pyx_v_site_fracs)); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 170, __pyx_L1_error)
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 170, __pyx_L1_error)
__pyx_v_num_vars = (__pyx_t_8 + __pyx_t_15);
</pre><pre class="cython line score-44" onclick='toggleDiv(this)'>+<span class="">171</span>: <span class="n">l_hessian</span><span class="p">,</span> <span class="n">gradient_term</span> <span class="o">=</span> <span class="n">_build_multiphase_system</span><span class="p">(</span><span class="n">dbf</span><span class="p">,</span> <span class="n">comps</span><span class="p">,</span> <span class="n">phases</span><span class="p">,</span> <span class="n">cur_conds</span><span class="p">,</span> <span class="n">site_fracs</span><span class="p">,</span> <span class="n">phase_fracs</span><span class="p">,</span></pre>
<pre class='cython code score-44 '> <span class='trace'>__Pyx_TraceLine</span>(171,0,__PYX_ERR(0, 171, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_build_multiphase_system); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
/* … */
<span class='trace'>__Pyx_TraceLine</span>(171,0,__PYX_ERR(0, 171, __pyx_L1_error))
if (!(likely(((__pyx_t_4) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 171, __pyx_L1_error)
if (!(likely(((__pyx_t_7) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 171, __pyx_L1_error)
__pyx_t_29 = ((PyArrayObject *)__pyx_t_4);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_hessian.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_hessian.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_hessian.rcbuffer->pybuffer, (PyObject*)__pyx_v_l_hessian, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_l_hessian.diminfo[0].strides = __pyx_pybuffernd_l_hessian.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_l_hessian.diminfo[0].shape = __pyx_pybuffernd_l_hessian.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_l_hessian.diminfo[1].strides = __pyx_pybuffernd_l_hessian.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_l_hessian.diminfo[1].shape = __pyx_pybuffernd_l_hessian.rcbuffer->pybuffer.shape[1];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
}
__pyx_t_29 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_l_hessian, ((PyArrayObject *)__pyx_t_4));
__pyx_t_4 = 0;
__pyx_t_28 = ((PyArrayObject *)__pyx_t_7);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_gradient_term.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_gradient_term.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_gradient_term.rcbuffer->pybuffer, (PyObject*)__pyx_v_gradient_term, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_gradient_term.diminfo[0].strides = __pyx_pybuffernd_gradient_term.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gradient_term.diminfo[0].shape = __pyx_pybuffernd_gradient_term.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
}
__pyx_t_28 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_gradient_term, ((PyArrayObject *)__pyx_t_7));
__pyx_t_7 = 0;
</pre><pre class="cython line score-0"> <span class="">172</span>: <span class="n">l_constraints</span><span class="p">,</span> <span class="n">constraint_jac</span><span class="p">,</span> <span class="n">constraint_hess</span><span class="p">,</span></pre>
<pre class="cython line score-104" onclick='toggleDiv(this)'>+<span class="">173</span>: <span class="n">l_multipliers</span><span class="p">,</span> <span class="n">callable_dict</span><span class="p">,</span> <span class="n">phase_records</span><span class="p">)</span></pre>
<pre class='cython code score-104 '> <span class='trace'>__Pyx_TraceLine</span>(173,0,__PYX_ERR(0, 173, __pyx_L1_error))
__pyx_t_3 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[13] = {__pyx_t_3, __pyx_v_dbf, __pyx_v_comps, __pyx_v_phases, __pyx_v_cur_conds, ((PyObject *)__pyx_v_site_fracs), ((PyObject *)__pyx_v_phase_fracs), ((PyObject *)__pyx_v_l_constraints), ((PyObject *)__pyx_v_constraint_jac), __pyx_v_constraint_hess, ((PyObject *)__pyx_v_l_multipliers), __pyx_v_callable_dict, __pyx_v_phase_records};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 12+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[13] = {__pyx_t_3, __pyx_v_dbf, __pyx_v_comps, __pyx_v_phases, __pyx_v_cur_conds, ((PyObject *)__pyx_v_site_fracs), ((PyObject *)__pyx_v_phase_fracs), ((PyObject *)__pyx_v_l_constraints), ((PyObject *)__pyx_v_constraint_jac), __pyx_v_constraint_hess, ((PyObject *)__pyx_v_l_multipliers), __pyx_v_callable_dict, __pyx_v_phase_records};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 12+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(12+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (__pyx_t_3) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_dbf);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_dbf);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+__pyx_t_17, __pyx_v_dbf);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comps);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comps);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1+__pyx_t_17, __pyx_v_comps);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phases);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 2+__pyx_t_17, __pyx_v_phases);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 3+__pyx_t_17, __pyx_v_cur_conds);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 4+__pyx_t_17, ((PyObject *)__pyx_v_site_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 5+__pyx_t_17, ((PyObject *)__pyx_v_phase_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_constraints));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_constraints));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 6+__pyx_t_17, ((PyObject *)__pyx_v_l_constraints));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 7+__pyx_t_17, ((PyObject *)__pyx_v_constraint_jac));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_constraint_hess);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_constraint_hess);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 8+__pyx_t_17, __pyx_v_constraint_hess);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 9+__pyx_t_17, ((PyObject *)__pyx_v_l_multipliers));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_callable_dict);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_callable_dict);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 10+__pyx_t_17, __pyx_v_callable_dict);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phase_records);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phase_records);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 11+__pyx_t_17, __pyx_v_phase_records);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_11))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
PyObject* sequence = __pyx_t_11;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(2);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 171, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_4 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_7 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
} else {
__pyx_t_4 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_7 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
#else
__pyx_t_4 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_7 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_3 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext;
index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L60_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
index = 1; __pyx_t_7 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_7)) goto __pyx_L60_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_3), 2) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
goto __pyx_L61_unpacking_done;
__pyx_L60_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 171, __pyx_L1_error)
__pyx_L61_unpacking_done:;
}
</pre><pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">174</span>: <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">l_hessian</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(174,0,__PYX_ERR(0, 174, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_any); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_isnan); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
}
}
if (!__pyx_t_3) {
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, ((PyObject *)__pyx_v_l_hessian)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
} else
#endif
{
__pyx_t_14 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0, __pyx_t_3); __pyx_t_3 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0+1, ((PyObject *)__pyx_v_l_hessian));
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function);
}
}
if (!__pyx_t_2) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_7};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_7};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
{
__pyx_t_14 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0, __pyx_t_2); __pyx_t_2 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_14, 0+1, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 174, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">175</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Invalid l_hessian'</span><span class="p">)</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(175,0,__PYX_ERR(0, 175, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 175, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
/* … */
__pyx_tuple__14 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Invalid_l_hessian); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 175, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__14);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__14);
</pre><pre class="cython line score-67" onclick='toggleDiv(this)'>+<span class="">176</span>: <span class="n">l_hessian</span><span class="p">[:,:]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="n">l_hessian</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">])</span></pre>
<pre class='cython code score-67 '> <span class='trace'>__Pyx_TraceLine</span>(176,0,__PYX_ERR(0, 176, __pyx_L1_error))
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_eye); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyInt_From_Py_intptr_t</span>((__pyx_v_l_hessian->dimensions[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
}
}
if (!__pyx_t_7) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_14, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
/* … */
__pyx_slice__15 = <span class='py_c_api'>PySlice_New</span>(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__15);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__15);
__pyx_slice__16 = <span class='py_c_api'>PySlice_New</span>(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__16);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__16);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(((PyObject *)__pyx_v_l_hessian), __pyx_tuple__17, __pyx_t_11) < 0)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_tuple__17 = <span class='py_c_api'>PyTuple_Pack</span>(2, __pyx_slice__15, __pyx_slice__16); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 176, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__17);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__17);
</pre><pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">177</span>: <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">gradient_term</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(177,0,__PYX_ERR(0, 177, __pyx_L1_error))
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_any); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_isnan); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
__pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
if (likely(__pyx_t_4)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
}
}
if (!__pyx_t_4) {
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_7, ((PyObject *)__pyx_v_gradient_term)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_gradient_term)};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_gradient_term)};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_gradient_term));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_gradient_term));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_gradient_term));
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
}
}
if (!__pyx_t_7) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_14};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_14};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+1, __pyx_t_14);
__pyx_t_14 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">178</span>: <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">'Invalid gradient_term'</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(178,0,__PYX_ERR(0, 178, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 178, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_11, 0, 0, 0);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__PYX_ERR(0, 178, __pyx_L1_error)
/* … */
__pyx_tuple__18 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Invalid_gradient_term); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 178, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__18);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__18);
</pre><pre class="cython line score-0"> <span class="">179</span>: <span class="c"># Equation 18.18 in Nocedal and Wright</span></pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">180</span>: <span class="k">if</span> <span class="n">m</span> <span class="o">!=</span> <span class="n">n</span><span class="p">:</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(180,0,__PYX_ERR(0, 180, __pyx_L1_error))
__pyx_t_5 = ((__pyx_v_m != __pyx_v_n) != 0);
if (__pyx_t_5) {
/* … */
goto __pyx_L64;
}
</pre><pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">181</span>: <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">zmat</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(181,0,__PYX_ERR(0, 181, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_isnan); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
}
}
if (!__pyx_t_14) {
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_7, ((PyObject *)__pyx_v_zmat)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_zmat)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_zmat)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
{
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_14); __pyx_t_14 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_zmat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_zmat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_zmat));
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_7) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_2};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
{
__pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0+1, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">182</span>: <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">'Invalid zmat'</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(182,0,__PYX_ERR(0, 182, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 182, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_c_api'>__Pyx_Raise</span>(__pyx_t_11, 0, 0, 0);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__PYX_ERR(0, 182, __pyx_L1_error)
/* … */
__pyx_tuple__19 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_Invalid_zmat); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 182, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__19);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__19);
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">183</span>: <span class="k">try</span><span class="p">:</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(183,0,__PYX_ERR(0, 183, __pyx_L66_error))
{
/*try:*/ {
/* … */
}
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_23); __pyx_t_23 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_22); __pyx_t_22 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_21); __pyx_t_21 = 0;
goto __pyx_L73_try_end;
__pyx_L66_error:;
__Pyx_PyThreadState_assign
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_31); __pyx_t_31 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
/* … */
__Pyx_PyThreadState_assign
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_23);
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_22);
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_ExceptionReset</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
goto __pyx_L1_error;
__pyx_L67_exception_handled:;
__Pyx_PyThreadState_assign
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_23);
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_22);
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_ExceptionReset</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
__pyx_L73_try_end:;
}
</pre><pre class="cython line score-96" onclick='toggleDiv(this)'>+<span class="">184</span>: <span class="n">p_z</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">solve</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">zmat</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">l_hessian</span><span class="p">),</span> <span class="n">zmat</span><span class="p">),</span></pre>
<pre class='cython code score-96 '> <span class='trace'>__Pyx_TraceLine</span>(184,0,__PYX_ERR(0, 184, __pyx_L66_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_linalg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_solve); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_zmat), __pyx_n_s_T); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
__pyx_t_10 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_1))) {
__pyx_t_10 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_1);
if (likely(__pyx_t_10)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_1, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_1)) {
PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_14, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_1, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_1)) {
PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_14, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_1, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (__pyx_t_10) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+__pyx_t_17, __pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 1+__pyx_t_17, ((PyObject *)__pyx_v_l_hessian));
__pyx_t_14 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {
__pyx_t_1 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);
if (likely(__pyx_t_1)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_v_zmat)};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_7)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_v_zmat)};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_7, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (__pyx_t_1) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+__pyx_t_17, __pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_zmat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_zmat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 1+__pyx_t_17, ((PyObject *)__pyx_v_zmat));
__pyx_t_2 = 0;
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
</pre><pre class="cython line score-229" onclick='toggleDiv(this)'>+<span class="">185</span>: <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">zmat</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">l_hessian</span><span class="p">),</span> <span class="n">ymat</span><span class="p">),</span> <span class="n">p_y</span><span class="p">)</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">zmat</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">gradient_term</span><span class="p">))</span></pre>
<pre class='cython code score-229 '> <span class='trace'>__Pyx_TraceLine</span>(185,0,__PYX_ERR(0, 185, __pyx_L66_error))
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_zmat), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_31 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_30))) {
__pyx_t_31 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_30);
if (likely(__pyx_t_31)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_31);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_30, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[3] = {__pyx_t_31, __pyx_t_10, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_31); __pyx_t_31 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[3] = {__pyx_t_31, __pyx_t_10, ((PyObject *)__pyx_v_l_hessian)};
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_31); __pyx_t_31 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (__pyx_t_31) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_31); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_31); __pyx_t_31 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+__pyx_t_17, __pyx_t_10);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 1+__pyx_t_17, ((PyObject *)__pyx_v_l_hessian));
__pyx_t_10 = 0;
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_30, __pyx_t_32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_30 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_30)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[3] = {__pyx_t_30, __pyx_t_1, ((PyObject *)__pyx_v_ymat)};
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[3] = {__pyx_t_30, __pyx_t_1, ((PyObject *)__pyx_v_ymat)};
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (__pyx_t_30) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_30); __pyx_t_30 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+__pyx_t_17, __pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_ymat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_ymat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 1+__pyx_t_17, ((PyObject *)__pyx_v_ymat));
__pyx_t_1 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_32, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, ((PyObject *)__pyx_v_p_y)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_12, ((PyObject *)__pyx_v_p_y)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (__pyx_t_14) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_14); __pyx_t_14 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+__pyx_t_17, __pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_p_y));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_p_y));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 1+__pyx_t_17, ((PyObject *)__pyx_v_p_y));
__pyx_t_12 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_32, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyNumber_Negative</span>(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_zmat), __pyx_n_s_T); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_14 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_14 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_14)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_32, ((PyObject *)__pyx_v_gradient_term)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_32, ((PyObject *)__pyx_v_gradient_term)};
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
} else
#endif
{
__pyx_t_1 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (__pyx_t_14) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 0, __pyx_t_14); __pyx_t_14 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 0+__pyx_t_17, __pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_gradient_term));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_gradient_term));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_1, 1+__pyx_t_17, ((PyObject *)__pyx_v_gradient_term));
__pyx_t_32 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_7 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_7)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_7);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_t_12};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_t_12};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (__pyx_t_7) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+__pyx_t_17, __pyx_t_4);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 1+__pyx_t_17, __pyx_t_12);
__pyx_t_4 = 0;
__pyx_t_12 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L66_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_p_z, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-15" onclick='toggleDiv(this)'>+<span class="">186</span>: <span class="k">except</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">LinAlgError</span><span class="p">:</span></pre>
<pre class='cython code score-15 '> <span class='trace'>__Pyx_TraceLine</span>(186,0,__PYX_ERR(0, 186, __pyx_L68_except_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 186, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_LinAlgError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 186, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_PyErr_ExceptionMatches</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_17) {
<span class='pyx_c_api'>__Pyx_AddTraceback</span>("_cython_magic_179ec25e50428c13c53b0ba863f4b74e._solve_eq_at_conditions", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (<span class='pyx_c_api'>__Pyx_GetException</span>(&__pyx_t_11, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 186, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
</pre><pre class="cython line score-38" onclick='toggleDiv(this)'>+<span class="">187</span>: <span class="n">p_z</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">zmat</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">1</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">)</span></pre>
<pre class='cython code score-38 '> <span class='trace'>__Pyx_TraceLine</span>(187,0,__PYX_ERR(0, 187, __pyx_L68_except_error))
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyInt_From_Py_intptr_t</span>((__pyx_v_zmat->dimensions[1])); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_12);
__pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_float); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_32) < 0) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_7, __pyx_t_12); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 187, __pyx_L68_except_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_p_z, __pyx_t_32);
__pyx_t_32 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
goto __pyx_L67_exception_handled;
}
goto __pyx_L68_except_error;
__pyx_L68_except_error:;
</pre><pre class="cython line score-112" onclick='toggleDiv(this)'>+<span class="">188</span>: <span class="n">step</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">ymat</span><span class="p">,</span> <span class="n">p_y</span><span class="p">)</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">zmat</span><span class="p">,</span> <span class="n">p_z</span><span class="p">)</span></pre>
<pre class='cython code score-112 '> <span class='trace'>__Pyx_TraceLine</span>(188,0,__PYX_ERR(0, 188, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_ymat), ((PyObject *)__pyx_v_p_y)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_ymat), ((PyObject *)__pyx_v_p_y)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (__pyx_t_3) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_3); __pyx_t_3 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_ymat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_ymat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+__pyx_t_17, ((PyObject *)__pyx_v_ymat));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_p_y));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_p_y));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 1+__pyx_t_17, ((PyObject *)__pyx_v_p_y));
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_32 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_32)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_32, ((PyObject *)__pyx_v_zmat), __pyx_v_p_z};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_32, ((PyObject *)__pyx_v_zmat), __pyx_v_p_z};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (__pyx_t_32) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_32); __pyx_t_32 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_zmat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_zmat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+__pyx_t_17, ((PyObject *)__pyx_v_zmat));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_p_z);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_p_z);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 1+__pyx_t_17, __pyx_v_p_z);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_2, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 188, __pyx_L1_error)
__pyx_t_28 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer, (PyObject*)__pyx_v_step, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_step.diminfo[0].strides = __pyx_pybuffernd_step.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_step.diminfo[0].shape = __pyx_pybuffernd_step.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 188, __pyx_L1_error)
}
__pyx_t_28 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_step, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-0"> <span class="">189</span>: <span class="k">else</span><span class="p">:</span></pre>
<pre class="cython line score-63" onclick='toggleDiv(this)'>+<span class="">190</span>: <span class="n">step</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">ymat</span><span class="p">,</span> <span class="n">p_y</span><span class="p">)</span></pre>
<pre class='cython code score-63 '> <span class='trace'>__Pyx_TraceLine</span>(190,0,__PYX_ERR(0, 190, __pyx_L1_error))
/*else*/ {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_11 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_11)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_ymat), ((PyObject *)__pyx_v_p_y)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_ymat), ((PyObject *)__pyx_v_p_y)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (__pyx_t_11) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_ymat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_ymat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+__pyx_t_17, ((PyObject *)__pyx_v_ymat));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_p_y));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_p_y));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 1+__pyx_t_17, ((PyObject *)__pyx_v_p_y));
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 190, __pyx_L1_error)
__pyx_t_28 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_step.rcbuffer->pybuffer, (PyObject*)__pyx_v_step, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_step.diminfo[0].strides = __pyx_pybuffernd_step.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_step.diminfo[0].shape = __pyx_pybuffernd_step.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
}
__pyx_t_28 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_step, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
}
__pyx_L64:;
</pre><pre class="cython line score-53" onclick='toggleDiv(this)'>+<span class="">191</span>: <span class="n">old_energy</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">])</span></pre>
<pre class='cython code score-53 '> <span class='trace'>__Pyx_TraceLine</span>(191,0,__PYX_ERR(0, 191, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_GM_values, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
}
}
if (!__pyx_t_2) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_11};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_11};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_2); __pyx_t_2 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_old_energy, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-53" onclick='toggleDiv(this)'>+<span class="">192</span>: <span class="n">old_chem_pots</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">])</span></pre>
<pre class='cython code score-53 '> <span class='trace'>__Pyx_TraceLine</span>(192,0,__PYX_ERR(0, 192, __pyx_L1_error))
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_copy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_11 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_MU_values, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_32))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_32);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_32, function);
}
}
if (!__pyx_t_12) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_32, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_12); __pyx_t_12 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_32, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_old_chem_pots, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-63" onclick='toggleDiv(this)'>+<span class="">193</span>: <span class="n">candidate_site_fracs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty_like</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">)</span></pre>
<pre class='cython code score-63 '> <span class='trace'>__Pyx_TraceLine</span>(193,0,__PYX_ERR(0, 193, __pyx_L1_error))
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_32 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_32)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
}
}
if (!__pyx_t_32) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, ((PyObject *)__pyx_v_site_fracs)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, ((PyObject *)__pyx_v_site_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, ((PyObject *)__pyx_v_site_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
{
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_32); __pyx_t_32 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0+1, ((PyObject *)__pyx_v_site_fracs));
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 193, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_v_candidate_site_fracs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_candidate_site_fracs.diminfo[0].strides = __pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_candidate_site_fracs.diminfo[0].shape = __pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 193, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_site_fracs, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-63" onclick='toggleDiv(this)'>+<span class="">194</span>: <span class="n">candidate_phase_fracs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">empty_like</span><span class="p">(</span><span class="n">phase_fracs</span><span class="p">)</span></pre>
<pre class='cython code score-63 '> <span class='trace'>__Pyx_TraceLine</span>(194,0,__PYX_ERR(0, 194, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_2) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, ((PyObject *)__pyx_v_phase_fracs)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_phase_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_phase_fracs)};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_2); __pyx_t_2 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_phase_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+1, ((PyObject *)__pyx_v_phase_fracs));
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (!(likely(((__pyx_t_3) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 194, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer, (PyObject*)__pyx_v_candidate_phase_fracs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_candidate_phase_fracs.diminfo[0].strides = __pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_candidate_phase_fracs.diminfo[0].shape = __pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_phase_fracs, ((PyArrayObject *)__pyx_t_3));
__pyx_t_3 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">195</span>: <span class="k">for</span> <span class="n">sfidx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">candidate_site_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]):</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(195,0,__PYX_ERR(0, 195, __pyx_L1_error))
__pyx_t_33 = (__pyx_v_candidate_site_fracs->dimensions[0]);
for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_33; __pyx_t_17+=1) {
__pyx_v_sfidx = __pyx_t_17;
</pre><pre class="cython line score-57" onclick='toggleDiv(this)'>+<span class="">196</span>: <span class="n">candidate_site_fracs</span><span class="p">[</span><span class="n">sfidx</span><span class="p">]</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">site_fracs</span><span class="p">[</span><span class="n">sfidx</span><span class="p">]</span> <span class="o">+</span> <span class="n">step</span><span class="p">[</span><span class="n">sfidx</span><span class="p">],</span> <span class="n">MIN_SITE_FRACTION</span><span class="p">),</span> <span class="mf">1</span><span class="p">)</span></pre>
<pre class='cython code score-57 '> <span class='trace'>__Pyx_TraceLine</span>(196,0,__PYX_ERR(0, 196, __pyx_L1_error))
__pyx_t_34 = 1;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SITE_FRACTION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_35 = __pyx_v_sfidx;
__pyx_t_36 = -1;
if (__pyx_t_35 < 0) {
__pyx_t_35 += __pyx_pybuffernd_site_fracs.diminfo[0].shape;
if (unlikely(__pyx_t_35 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_site_fracs.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 196, __pyx_L1_error)
}
__pyx_t_37 = __pyx_v_sfidx;
__pyx_t_36 = -1;
if (__pyx_t_37 < 0) {
__pyx_t_37 += __pyx_pybuffernd_step.diminfo[0].shape;
if (unlikely(__pyx_t_37 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_37 >= __pyx_pybuffernd_step.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 196, __pyx_L1_error)
}
__pyx_t_38 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_site_fracs.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_site_fracs.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_step.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_step.diminfo[0].strides)));
__pyx_t_32 = <span class='py_c_api'>PyFloat_FromDouble</span>(__pyx_t_38); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_2 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_3, __pyx_t_32, Py_GT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_5) {
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
__pyx_t_11 = __pyx_t_3;
} else {
__pyx_t_2 = <span class='py_c_api'>PyFloat_FromDouble</span>(__pyx_t_38); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = __pyx_t_2;
__pyx_t_2 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
__pyx_t_3 = __pyx_t_11;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>(__pyx_t_34); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_32 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_2, __pyx_t_3, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_32); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_32); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
if (__pyx_t_5) {
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>(__pyx_t_34); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_11 = __pyx_t_32;
__pyx_t_32 = 0;
} else {
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
__pyx_t_11 = __pyx_t_3;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_38 = __pyx_<span class='py_c_api'>PyFloat_AsDouble</span>(__pyx_t_11); if (unlikely((__pyx_t_38 == ((npy_float64)-1)) && <span class='py_c_api'>PyErr_Occurred</span>())) __PYX_ERR(0, 196, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_39 = __pyx_v_sfidx;
__pyx_t_36 = -1;
if (__pyx_t_39 < 0) {
__pyx_t_39 += __pyx_pybuffernd_candidate_site_fracs.diminfo[0].shape;
if (unlikely(__pyx_t_39 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_candidate_site_fracs.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 196, __pyx_L1_error)
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_candidate_site_fracs.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_candidate_site_fracs.diminfo[0].strides) = __pyx_t_38;
}
</pre><pre class="cython line score-0"> <span class="">197</span>: </pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">198</span>: <span class="k">for</span> <span class="n">pfidx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">candidate_phase_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]):</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(198,0,__PYX_ERR(0, 198, __pyx_L1_error))
__pyx_t_33 = (__pyx_v_candidate_phase_fracs->dimensions[0]);
for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_33; __pyx_t_17+=1) {
__pyx_v_pfidx = __pyx_t_17;
</pre><pre class="cython line score-6" onclick='toggleDiv(this)'>+<span class="">199</span>: <span class="n">candidate_phase_fracs</span><span class="p">[</span><span class="n">pfidx</span><span class="p">]</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">phase_fracs</span><span class="p">[</span><span class="n">pfidx</span><span class="p">]</span> <span class="o">+</span> <span class="n">step</span><span class="p">[</span><span class="n">candidate_site_fracs</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">pfidx</span><span class="p">],</span> <span class="mf">0</span><span class="p">),</span> <span class="mf">1</span><span class="p">)</span></pre>
<pre class='cython code score-6 '> <span class='trace'>__Pyx_TraceLine</span>(199,0,__PYX_ERR(0, 199, __pyx_L1_error))
__pyx_t_34 = 1;
__pyx_t_40 = 0;
__pyx_t_41 = __pyx_v_pfidx;
__pyx_t_36 = -1;
if (__pyx_t_41 < 0) {
__pyx_t_41 += __pyx_pybuffernd_phase_fracs.diminfo[0].shape;
if (unlikely(__pyx_t_41 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_41 >= __pyx_pybuffernd_phase_fracs.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 199, __pyx_L1_error)
}
__pyx_t_42 = ((__pyx_v_candidate_site_fracs->dimensions[0]) + __pyx_v_pfidx);
__pyx_t_36 = -1;
if (__pyx_t_42 < 0) {
__pyx_t_42 += __pyx_pybuffernd_step.diminfo[0].shape;
if (unlikely(__pyx_t_42 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_42 >= __pyx_pybuffernd_step.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 199, __pyx_L1_error)
}
__pyx_t_38 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_phase_fracs.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_phase_fracs.diminfo[0].strides)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_step.rcbuffer->pybuffer.buf, __pyx_t_42, __pyx_pybuffernd_step.diminfo[0].strides)));
if (((__pyx_t_40 > __pyx_t_38) != 0)) {
__pyx_t_43 = __pyx_t_40;
} else {
__pyx_t_43 = __pyx_t_38;
}
__pyx_t_38 = __pyx_t_43;
if (((__pyx_t_34 < __pyx_t_38) != 0)) {
__pyx_t_43 = __pyx_t_34;
} else {
__pyx_t_43 = __pyx_t_38;
}
__pyx_t_44 = __pyx_v_pfidx;
__pyx_t_36 = -1;
if (__pyx_t_44 < 0) {
__pyx_t_44 += __pyx_pybuffernd_candidate_phase_fracs.diminfo[0].shape;
if (unlikely(__pyx_t_44 < 0)) __pyx_t_36 = 0;
} else if (unlikely(__pyx_t_44 >= __pyx_pybuffernd_candidate_phase_fracs.diminfo[0].shape)) __pyx_t_36 = 0;
if (unlikely(__pyx_t_36 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_36);
__PYX_ERR(0, 199, __pyx_L1_error)
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_candidate_phase_fracs.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_candidate_phase_fracs.diminfo[0].strides) = __pyx_t_43;
}
</pre><pre class="cython line score-3" onclick='toggleDiv(this)'>+<span class="">200</span>: <span class="n">candidate_l_constraints</span><span class="p">,</span> <span class="n">candidate_constraint_jac</span><span class="p">,</span> <span class="n">candidate_constraint_hess</span> <span class="o">=</span> \</pre>
<pre class='cython code score-3 '> <span class='trace'>__Pyx_TraceLine</span>(200,0,__PYX_ERR(0, 200, __pyx_L1_error))
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_l_constraints, __pyx_t_32);
__pyx_t_32 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_constraint_jac, __pyx_t_3);
__pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_constraint_hess, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-77" onclick='toggleDiv(this)'>+<span class="">201</span>: <span class="n">_compute_constraints</span><span class="p">(</span><span class="n">dbf</span><span class="p">,</span> <span class="n">comps</span><span class="p">,</span> <span class="n">phases</span><span class="p">,</span> <span class="n">cur_conds</span><span class="p">,</span></pre>
<pre class='cython code score-77 '> <span class='trace'>__Pyx_TraceLine</span>(201,0,__PYX_ERR(0, 201, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_compute_constraints); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 201, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
/* … */
<span class='trace'>__Pyx_TraceLine</span>(202,0,__PYX_ERR(0, 202, __pyx_L1_error))
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 201, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_dbf);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_dbf);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_v_dbf);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comps);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comps);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1, __pyx_v_comps);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phases);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 2, __pyx_v_phases);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 3, __pyx_v_cur_conds);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_candidate_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_candidate_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 4, ((PyObject *)__pyx_v_candidate_site_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 5, ((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phase_records);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phase_records);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 6, __pyx_v_phase_records);
/* … */
<span class='trace'>__Pyx_TraceLine</span>(201,0,__PYX_ERR(0, 201, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_3, __pyx_t_32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_2))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 3)) {
if (size > 3) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(3);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 200, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_32 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_3 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 2);
} else {
__pyx_t_32 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_3 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 2);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
#else
__pyx_t_32 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 200, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_3 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 200, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_12 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
index = 0; __pyx_t_32 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_32)) goto __pyx_L80_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
index = 1; __pyx_t_3 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_3)) goto __pyx_L80_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
index = 2; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L80_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_12), 3) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
goto __pyx_L81_unpacking_done;
__pyx_L80_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 200, __pyx_L1_error)
__pyx_L81_unpacking_done:;
}
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">202</span>: <span class="n">candidate_site_fracs</span><span class="p">,</span> <span class="n">candidate_phase_fracs</span><span class="p">,</span> <span class="n">phase_records</span><span class="p">,</span> <span class="n">mole_fractions</span><span class="o">=</span><span class="n">mole_fractions</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> __pyx_t_32 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 202, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_32, __pyx_n_s_mole_fractions, __pyx_v_mole_fractions) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">203</span>: <span class="n">candidate_energy</span><span class="p">,</span> <span class="n">candidate_gradient_term</span> <span class="o">=</span> \</pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(203,0,__PYX_ERR(0, 203, __pyx_L1_error))
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_energy, __pyx_t_11);
__pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_candidate_gradient_term, __pyx_t_32);
__pyx_t_32 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">204</span>: <span class="n">_build_multiphase_gradient</span><span class="p">(</span><span class="n">dbf</span><span class="p">,</span> <span class="n">comps</span><span class="p">,</span> <span class="n">phases</span><span class="p">,</span> <span class="n">cur_conds</span><span class="p">,</span> <span class="n">candidate_site_fracs</span><span class="p">,</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(204,0,__PYX_ERR(0, 204, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_build_multiphase_gradient); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 204, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
</pre><pre class="cython line score-0"> <span class="">205</span>: <span class="n">candidate_phase_fracs</span><span class="p">,</span> <span class="n">candidate_l_constraints</span><span class="p">,</span></pre>
<pre class="cython line score-0"> <span class="">206</span>: <span class="n">candidate_constraint_jac</span><span class="p">,</span> <span class="n">l_multipliers</span><span class="p">,</span></pre>
<pre class="cython line score-102" onclick='toggleDiv(this)'>+<span class="">207</span>: <span class="n">callable_dict</span><span class="p">,</span> <span class="n">phase_records</span><span class="p">)</span></pre>
<pre class='cython code score-102 '> <span class='trace'>__Pyx_TraceLine</span>(207,0,__PYX_ERR(0, 207, __pyx_L1_error))
__pyx_t_3 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[12] = {__pyx_t_3, __pyx_v_dbf, __pyx_v_comps, __pyx_v_phases, __pyx_v_cur_conds, ((PyObject *)__pyx_v_candidate_site_fracs), ((PyObject *)__pyx_v_candidate_phase_fracs), __pyx_v_candidate_l_constraints, __pyx_v_candidate_constraint_jac, ((PyObject *)__pyx_v_l_multipliers), __pyx_v_callable_dict, __pyx_v_phase_records};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 11+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[12] = {__pyx_t_3, __pyx_v_dbf, __pyx_v_comps, __pyx_v_phases, __pyx_v_cur_conds, ((PyObject *)__pyx_v_candidate_site_fracs), ((PyObject *)__pyx_v_candidate_phase_fracs), __pyx_v_candidate_l_constraints, __pyx_v_candidate_constraint_jac, ((PyObject *)__pyx_v_l_multipliers), __pyx_v_callable_dict, __pyx_v_phase_records};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 11+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(11+__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 204, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (__pyx_t_3) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_3); __pyx_t_3 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_dbf);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_dbf);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+__pyx_t_17, __pyx_v_dbf);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comps);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comps);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 1+__pyx_t_17, __pyx_v_comps);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phases);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phases);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 2+__pyx_t_17, __pyx_v_phases);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 3+__pyx_t_17, __pyx_v_cur_conds);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_candidate_site_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_candidate_site_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 4+__pyx_t_17, ((PyObject *)__pyx_v_candidate_site_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 5+__pyx_t_17, ((PyObject *)__pyx_v_candidate_phase_fracs));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_candidate_l_constraints);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_candidate_l_constraints);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 6+__pyx_t_17, __pyx_v_candidate_l_constraints);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_candidate_constraint_jac);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_candidate_constraint_jac);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 7+__pyx_t_17, __pyx_v_candidate_constraint_jac);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 8+__pyx_t_17, ((PyObject *)__pyx_v_l_multipliers));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_callable_dict);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_callable_dict);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 9+__pyx_t_17, __pyx_v_callable_dict);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_phase_records);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_phase_records);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 10+__pyx_t_17, __pyx_v_phase_records);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if ((likely(<span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_t_2))) || (<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
#if !CYTHON_COMPILING_IN_PYPY
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = <span class='py_c_api'>PySequence_Size</span>(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) <span class='pyx_c_api'>__Pyx_RaiseTooManyValuesError</span>(2);
else if (size >= 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(size);
__PYX_ERR(0, 203, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
if (likely(<span class='py_c_api'>PyTuple_CheckExact</span>(sequence))) {
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 0);
__pyx_t_32 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(sequence, 1);
} else {
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 0);
__pyx_t_32 = <span class='py_macro_api'>PyList_GET_ITEM</span>(sequence, 1);
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 203, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_32 = <span class='py_macro_api'>PySequence_ITEM</span>(sequence, 1); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 203, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
#endif
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_3 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext;
index = 0; __pyx_t_11 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_11)) goto __pyx_L82_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
index = 1; __pyx_t_32 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_32)) goto __pyx_L82_unpacking_failed;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
if (<span class='pyx_c_api'>__Pyx_IternextUnpackEndCheck</span>(__pyx_t_13(__pyx_t_3), 2) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
__pyx_t_13 = NULL;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
goto __pyx_L83_unpacking_done;
__pyx_L82_unpacking_failed:;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_13 = NULL;
if (<span class='pyx_c_api'>__Pyx_IterFinish</span>() == 0) <span class='pyx_c_api'>__Pyx_RaiseNeedMoreValuesError</span>(index);
__PYX_ERR(0, 203, __pyx_L1_error)
__pyx_L83_unpacking_done:;
}
</pre><pre class="cython line score-0"> <span class="">208</span>: <span class="c"># We updated degrees of freedom this iteration</span></pre>
<pre class="cython line score-74" onclick='toggleDiv(this)'>+<span class="">209</span>: <span class="n">new_l_multipliers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">solve</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">constraint_jac</span><span class="p">,</span> <span class="n">ymat</span><span class="p">)</span><span class="o">.</span><span class="n">T</span><span class="p">,</span></pre>
<pre class='cython code score-74 '> <span class='trace'>__Pyx_TraceLine</span>(209,0,__PYX_ERR(0, 209, __pyx_L1_error))
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_linalg); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_solve); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_constraint_jac), ((PyObject *)__pyx_v_ymat)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_constraint_jac), ((PyObject *)__pyx_v_ymat)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_7 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
if (__pyx_t_3) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_constraint_jac));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 0+__pyx_t_17, ((PyObject *)__pyx_v_constraint_jac));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_ymat));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_ymat));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_7, 1+__pyx_t_17, ((PyObject *)__pyx_v_ymat));
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_7, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_T); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(209,0,__PYX_ERR(0, 209, __pyx_L1_error))
if (!(likely(((__pyx_t_2) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 209, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_2);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_new_l_multipliers.diminfo[0].strides = __pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_l_multipliers.diminfo[0].shape = __pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 209, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_new_l_multipliers, ((PyArrayObject *)__pyx_t_2));
__pyx_t_2 = 0;
</pre><pre class="cython line score-133" onclick='toggleDiv(this)'>+<span class="">210</span>: <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">ymat</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">gradient_term</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">l_hessian</span><span class="p">,</span> <span class="n">step</span><span class="p">)))</span></pre>
<pre class='cython code score-133 '> <span class='trace'>__Pyx_TraceLine</span>(210,0,__PYX_ERR(0, 210, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(((PyObject *)__pyx_v_ymat), __pyx_n_s_T); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_1 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_14))) {
__pyx_t_1 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_14);
if (likely(__pyx_t_1)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_14, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_l_hessian), ((PyObject *)__pyx_v_step)};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_14)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_l_hessian), ((PyObject *)__pyx_v_step)};
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_14, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
} else
#endif
{
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (__pyx_t_1) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_1); __pyx_t_1 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_hessian));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0+__pyx_t_17, ((PyObject *)__pyx_v_l_hessian));
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_step));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_step));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1+__pyx_t_17, ((PyObject *)__pyx_v_step));
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_14, __pyx_t_30, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_14 = <span class='py_c_api'>PyNumber_Add</span>(((PyObject *)__pyx_v_gradient_term), __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_4)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_7, __pyx_t_14};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_7, __pyx_t_14};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
{
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (__pyx_t_4) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_4); __pyx_t_4 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0+__pyx_t_17, __pyx_t_7);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1+__pyx_t_17, __pyx_t_14);
__pyx_t_7 = 0;
__pyx_t_14 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_30, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_32))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_32);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_32, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_12, __pyx_t_11};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_12, __pyx_t_11};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
{
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (__pyx_t_3) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_3); __pyx_t_3 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0+__pyx_t_17, __pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1+__pyx_t_17, __pyx_t_11);
__pyx_t_12 = 0;
__pyx_t_11 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_32, __pyx_t_30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
</pre><pre class="cython line score-30" onclick='toggleDiv(this)'>+<span class="">211</span>: <span class="n">np</span><span class="o">.</span><span class="n">clip</span><span class="p">(</span><span class="n">new_l_multipliers</span><span class="p">,</span> <span class="o">-</span><span class="n">MAX_ABS_LAGRANGE_MULTIPLIER</span><span class="p">,</span> <span class="n">MAX_ABS_LAGRANGE_MULTIPLIER</span><span class="p">,</span></pre>
<pre class='cython code score-30 '> <span class='trace'>__Pyx_TraceLine</span>(211,0,__PYX_ERR(0, 211, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_clip); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_ABS_LAGRANGE_MULTIPLIER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_30 = <span class='py_c_api'>PyNumber_Negative</span>(__pyx_t_2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_ABS_LAGRANGE_MULTIPLIER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, ((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1, __pyx_t_30);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 2, __pyx_t_2);
__pyx_t_30 = 0;
__pyx_t_2 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(211,0,__PYX_ERR(0, 211, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_32, __pyx_t_11, __pyx_t_2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 211, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">212</span>: <span class="n">out</span><span class="o">=</span><span class="n">new_l_multipliers</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(212,0,__PYX_ERR(0, 212, __pyx_L1_error))
__pyx_t_2 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_2, __pyx_n_s_out, ((PyObject *)__pyx_v_new_l_multipliers)) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
</pre><pre class="cython line score-0"> <span class="">213</span>: <span class="c"># XXX: Should fix underlying numerical problem at edges of composition space instead of working around</span></pre>
<pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">214</span>: <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">new_l_multipliers</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(214,0,__PYX_ERR(0, 214, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_any); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_isnan); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_32 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_32)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
}
}
if (!__pyx_t_32) {
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_12, ((PyObject *)__pyx_v_new_l_multipliers)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, ((PyObject *)__pyx_v_new_l_multipliers)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, ((PyObject *)__pyx_v_new_l_multipliers)};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_32); __pyx_t_32 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_new_l_multipliers));
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_12) {
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_2};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_2};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
{
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_12); __pyx_t_12 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0+1, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_30); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 214, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-13" onclick='toggleDiv(this)'>+<span class="">215</span>: <span class="k">print</span><span class="p">(</span><span class="s">'WARNING: Unstable Lagrange multipliers: '</span><span class="p">,</span> <span class="n">new_l_multipliers</span><span class="p">)</span></pre>
<pre class='cython code score-13 '> <span class='trace'>__Pyx_TraceLine</span>(215,0,__PYX_ERR(0, 215, __pyx_L1_error))
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 215, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_WARNING_Unstable_Lagrange_multip);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_WARNING_Unstable_Lagrange_multip);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_kp_u_WARNING_Unstable_Lagrange_multip);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1, ((PyObject *)__pyx_v_new_l_multipliers));
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_30, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 215, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-0"> <span class="">216</span>: <span class="c"># Equation 18.16 in Nocedal and Wright</span></pre>
<pre class="cython line score-0"> <span class="">217</span>: <span class="c"># This method is less accurate but more stable</span></pre>
<pre class="cython line score-44" onclick='toggleDiv(this)'>+<span class="">218</span>: <span class="n">new_l_multipliers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">candidate_constraint_jac</span><span class="p">,</span></pre>
<pre class='cython code score-44 '> <span class='trace'>__Pyx_TraceLine</span>(218,0,__PYX_ERR(0, 218, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_30, __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_linalg); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_14, __pyx_n_s_inv); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(218,0,__PYX_ERR(0, 218, __pyx_L1_error))
if (!(likely(((__pyx_t_11) == Py_None) || likely(<span class='pyx_c_api'>__Pyx_TypeTest</span>(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 218, __pyx_L1_error)
__pyx_t_20 = ((PyArrayObject *)__pyx_t_11);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_23, __pyx_t_22, __pyx_t_21);
}
}
__pyx_pybuffernd_new_l_multipliers.diminfo[0].strides = __pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_l_multipliers.diminfo[0].shape = __pyx_pybuffernd_new_l_multipliers.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 218, __pyx_L1_error)
}
__pyx_t_20 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_new_l_multipliers, ((PyArrayObject *)__pyx_t_11));
__pyx_t_11 = 0;
</pre><pre class="cython line score-79" onclick='toggleDiv(this)'>+<span class="">219</span>: <span class="n">candidate_constraint_jac</span><span class="o">.</span><span class="n">T</span><span class="p">)),</span></pre>
<pre class='cython code score-79 '> <span class='trace'>__Pyx_TraceLine</span>(219,0,__PYX_ERR(0, 219, __pyx_L1_error))
__pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_candidate_constraint_jac, __pyx_n_s_T); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 219, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);
__pyx_t_1 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_4))) {
__pyx_t_1 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_4);
if (likely(__pyx_t_1)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_1);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_4, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_candidate_constraint_jac, __pyx_t_7};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_candidate_constraint_jac, __pyx_t_7};
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;
} else
#endif
{
__pyx_t_10 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
if (__pyx_t_1) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_candidate_constraint_jac);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_candidate_constraint_jac);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0+__pyx_t_17, __pyx_v_candidate_constraint_jac);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_7);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 1+__pyx_t_17, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_14 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_14);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_32))) {
__pyx_t_4 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_32);
if (likely(__pyx_t_4)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_4);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_32, function);
}
}
if (!__pyx_t_4) {
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_32, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_14};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_32)) {
PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_14};
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_32, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4); __pyx_t_4 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_14); __pyx_t_14 = 0;
} else
#endif
{
__pyx_t_10 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_14);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0+1, __pyx_t_14);
__pyx_t_14 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_32, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
</pre><pre class="cython line score-76" onclick='toggleDiv(this)'>+<span class="">220</span>: <span class="n">candidate_constraint_jac</span><span class="p">),</span> <span class="n">candidate_gradient_term</span><span class="p">)</span></pre>
<pre class='cython code score-76 '> <span class='trace'>__Pyx_TraceLine</span>(220,0,__PYX_ERR(0, 220, __pyx_L1_error))
__pyx_t_32 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_32 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_32)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_32, __pyx_t_2, __pyx_v_candidate_constraint_jac};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[3] = {__pyx_t_32, __pyx_t_2, __pyx_v_candidate_constraint_jac};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
} else
#endif
{
__pyx_t_10 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
if (__pyx_t_32) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0, __pyx_t_32); __pyx_t_32 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0+__pyx_t_17, __pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_candidate_constraint_jac);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_candidate_constraint_jac);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 1+__pyx_t_17, __pyx_v_candidate_constraint_jac);
__pyx_t_2 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_10, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
__pyx_t_17 = 0;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
__pyx_t_17 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_30, __pyx_v_candidate_gradient_term};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_30, __pyx_v_candidate_gradient_term};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
} else
#endif
{
__pyx_t_10 = <span class='py_c_api'>PyTuple_New</span>(2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
if (__pyx_t_12) {
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL;
}
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0+__pyx_t_17, __pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_candidate_gradient_term);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_candidate_gradient_term);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 1+__pyx_t_17, __pyx_v_candidate_gradient_term);
__pyx_t_30 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-30" onclick='toggleDiv(this)'>+<span class="">221</span>: <span class="n">np</span><span class="o">.</span><span class="n">clip</span><span class="p">(</span><span class="n">new_l_multipliers</span><span class="p">,</span> <span class="o">-</span><span class="n">MAX_ABS_LAGRANGE_MULTIPLIER</span><span class="p">,</span> <span class="n">MAX_ABS_LAGRANGE_MULTIPLIER</span><span class="p">,</span></pre>
<pre class='cython code score-30 '> <span class='trace'>__Pyx_TraceLine</span>(221,0,__PYX_ERR(0, 221, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_clip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_ABS_LAGRANGE_MULTIPLIER); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_10 = <span class='py_c_api'>PyNumber_Negative</span>(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_ABS_LAGRANGE_MULTIPLIER); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(3); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, ((PyObject *)__pyx_v_new_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1, __pyx_t_10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 2, __pyx_t_11);
__pyx_t_10 = 0;
__pyx_t_11 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(221,0,__PYX_ERR(0, 221, __pyx_L1_error))
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_30, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
</pre><pre class="cython line score-10" onclick='toggleDiv(this)'>+<span class="">222</span>: <span class="n">out</span><span class="o">=</span><span class="n">new_l_multipliers</span><span class="p">)</span></pre>
<pre class='cython code score-10 '> <span class='trace'>__Pyx_TraceLine</span>(222,0,__PYX_ERR(0, 222, __pyx_L1_error))
__pyx_t_11 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 222, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_11, __pyx_n_s_out, ((PyObject *)__pyx_v_new_l_multipliers)) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
</pre><pre class="cython line score-20" onclick='toggleDiv(this)'>+<span class="">223</span>: <span class="n">l_multipliers</span> <span class="o">=</span> <span class="n">new_l_multipliers</span></pre>
<pre class='cython code score-20 '> <span class='trace'>__Pyx_TraceLine</span>(223,0,__PYX_ERR(0, 223, __pyx_L1_error))
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer);
__pyx_t_17 = <span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
if (unlikely(__pyx_t_17 < 0)) {
<span class='py_c_api'>PyErr_Fetch</span>(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer, (PyObject*)__pyx_v_l_multipliers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23);
<span class='pyx_c_api'>__Pyx_RaiseBufferFallbackError</span>();
} else {
<span class='py_c_api'>PyErr_Restore</span>(__pyx_t_21, __pyx_t_22, __pyx_t_23);
}
}
__pyx_pybuffernd_l_multipliers.diminfo[0].strides = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_l_multipliers.diminfo[0].shape = __pyx_pybuffernd_l_multipliers.rcbuffer->pybuffer.shape[0];
if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
}
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_new_l_multipliers));
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_l_multipliers, __pyx_v_new_l_multipliers);
</pre><pre class="cython line score-89" onclick='toggleDiv(this)'>+<span class="">224</span>: <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">l_multipliers</span><span class="p">)):</span></pre>
<pre class='cython code score-89 '> <span class='trace'>__Pyx_TraceLine</span>(224,0,__PYX_ERR(0, 224, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_any); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_isnan); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_12))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_12);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_12, function);
}
}
if (!__pyx_t_3) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_12, ((PyObject *)__pyx_v_l_multipliers)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_multipliers)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_12)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_l_multipliers)};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, ((PyObject *)__pyx_v_l_multipliers));
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_30))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_30);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_30, function);
}
}
if (!__pyx_t_12) {
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_30, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_12); __pyx_t_12 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_30, __pyx_t_2, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-13" onclick='toggleDiv(this)'>+<span class="">225</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Invalid l_multipliers after recalculation'</span><span class="p">,</span> <span class="n">l_multipliers</span><span class="p">)</span></pre>
<pre class='cython code score-13 '> <span class='trace'>__Pyx_TraceLine</span>(225,0,__PYX_ERR(0, 225, __pyx_L1_error))
__pyx_t_10 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 225, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_Invalid_l_multipliers_after_reca);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_Invalid_l_multipliers_after_reca);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 0, __pyx_kp_u_Invalid_l_multipliers_after_reca);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_10, 1, ((PyObject *)__pyx_v_l_multipliers));
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_10, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 225, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-7" onclick='toggleDiv(this)'>+<span class="">226</span>: <span class="n">l_multipliers</span><span class="p">[:]</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-7 '> <span class='trace'>__Pyx_TraceLine</span>(226,0,__PYX_ERR(0, 226, __pyx_L1_error))
if (<span class='pyx_c_api'>__Pyx_PyObject_SetSlice</span>(((PyObject *)__pyx_v_l_multipliers), __pyx_int_0, 0, 0, NULL, NULL, &__pyx_slice__20, 0, 0, 1) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
/* … */
__pyx_slice__20 = <span class='py_c_api'>PySlice_New</span>(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(0, 226, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_slice__20);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_slice__20);
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">227</span>: <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(227,0,__PYX_ERR(0, 227, __pyx_L1_error))
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_verbose); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 227, __pyx_L1_error)
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-13" onclick='toggleDiv(this)'>+<span class="">228</span>: <span class="k">print</span><span class="p">(</span><span class="s">'NEW_L_MULTIPLIERS'</span><span class="p">,</span> <span class="n">l_multipliers</span><span class="p">)</span></pre>
<pre class='cython code score-13 '> <span class='trace'>__Pyx_TraceLine</span>(228,0,__PYX_ERR(0, 228, __pyx_L1_error))
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 228, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_u_NEW_L_MULTIPLIERS);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_n_u_NEW_L_MULTIPLIERS);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_n_u_NEW_L_MULTIPLIERS);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='refnanny'>__Pyx_GIVEREF</span>(((PyObject *)__pyx_v_l_multipliers));
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1, ((PyObject *)__pyx_v_l_multipliers));
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_30, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 228, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
</pre><pre class="cython line score-38" onclick='toggleDiv(this)'>+<span class="">229</span>: <span class="n">num_mass_bals</span> <span class="o">=</span> <span class="nb">len</span><span class="p">([</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">cur_conds</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'X_'</span><span class="p">)])</span> <span class="o">+</span> <span class="mf">1</span></pre>
<pre class='cython code score-38 '> <span class='trace'>__Pyx_TraceLine</span>(229,0,__PYX_ERR(0, 229, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr4__pyx_v_i = NULL;
__pyx_t_10 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_15 = 0;
if (unlikely(__pyx_v_cur_conds == Py_None)) {
<span class='py_c_api'>PyErr_Format</span>(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "keys");
__PYX_ERR(0, 229, __pyx_L89_error)
}
__pyx_t_2 = __Pyx_dict_iterator(__pyx_v_cur_conds, 0, __pyx_n_s_keys, (&__pyx_t_8), (&__pyx_t_17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30);
__pyx_t_30 = __pyx_t_2;
__pyx_t_2 = 0;
while (1) {
__pyx_t_36 = __Pyx_dict_iter_next(__pyx_t_30, __pyx_t_8, &__pyx_t_15, &__pyx_t_2, NULL, NULL, __pyx_t_17);
if (unlikely(__pyx_t_36 == 0)) break;
if (unlikely(__pyx_t_36 == -1)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr4__pyx_v_i, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_8genexpr4__pyx_v_i, __pyx_n_s_startswith); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 229, __pyx_L89_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_5) {
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_10, (PyObject*)__pyx_8genexpr4__pyx_v_i))) __PYX_ERR(0, 229, __pyx_L89_error)
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr4__pyx_v_i);
goto __pyx_L93_exit_scope;
__pyx_L89_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr4__pyx_v_i);
goto __pyx_L1_error;
__pyx_L93_exit_scope:;
} /* exit inner scope */
__pyx_t_8 = <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_10); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 229, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyInt_FromSsize_t</span>((__pyx_t_8 + 1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 229, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_num_mass_bals, __pyx_t_10);
__pyx_t_10 = 0;
/* … */
__pyx_tuple__21 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_u_X_2); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 229, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__21);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__21);
</pre><pre class="cython line score-92" onclick='toggleDiv(this)'>+<span class="">230</span>: <span class="n">chemical_potentials</span> <span class="o">=</span> <span class="n">l_multipliers</span><span class="p">[</span><span class="nb">sum</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sublattices</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">]):</span></pre>
<pre class='cython code score-92 '> <span class='trace'>__Pyx_TraceLine</span>(230,0,__PYX_ERR(0, 230, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr5__pyx_v_i = NULL;
__pyx_t_10 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_30 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_30); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_8 = -1; __pyx_t_30 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_9 = Py_TYPE(__pyx_t_30)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 230, __pyx_L96_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_30))) {
if (__pyx_t_8 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_30)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_30, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 230, __pyx_L96_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_30, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
} else {
if (__pyx_t_8 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_30)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_30, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 230, __pyx_L96_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_30, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
}
} else {
__pyx_t_11 = __pyx_t_9(__pyx_t_30);
if (unlikely(!__pyx_t_11)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 230, __pyx_L96_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr5__pyx_v_i, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_11, __pyx_8genexpr5__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_sublattices); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_11); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_10, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 230, __pyx_L96_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr5__pyx_v_i);
goto __pyx_L99_exit_scope;
__pyx_L96_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr5__pyx_v_i);
goto __pyx_L1_error;
__pyx_L99_exit_scope:;
} /* exit inner scope */
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 230, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_10);
__pyx_t_10 = 0;
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_sum, __pyx_t_30, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(230,0,__PYX_ERR(0, 230, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(((PyObject *)__pyx_v_l_multipliers), 0, 0, &__pyx_t_10, &__pyx_t_11, NULL, 0, 0, 1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 230, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_chemical_potentials, __pyx_t_30);
__pyx_t_30 = 0;
</pre><pre class="cython line score-93" onclick='toggleDiv(this)'>+<span class="">231</span>: <span class="nb">sum</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sublattices</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">])</span> <span class="o">+</span> <span class="n">num_mass_bals</span><span class="p">]</span></pre>
<pre class='cython code score-93 '> <span class='trace'>__Pyx_TraceLine</span>(231,0,__PYX_ERR(0, 231, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr6__pyx_v_i = NULL;
__pyx_t_30 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_11 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_8 = -1; __pyx_t_11 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_9 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 231, __pyx_L102_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
if (__pyx_t_8 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_11, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 231, __pyx_L102_error)
#else
__pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
#endif
} else {
if (__pyx_t_8 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_11, __pyx_t_8); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 231, __pyx_L102_error)
#else
__pyx_t_2 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
#endif
}
} else {
__pyx_t_2 = __pyx_t_9(__pyx_t_11);
if (unlikely(!__pyx_t_2)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 231, __pyx_L102_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr6__pyx_v_i, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_12 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_2, __pyx_8genexpr6__pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_sublattices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_15 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_2); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_30, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 231, __pyx_L102_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr6__pyx_v_i);
goto __pyx_L105_exit_scope;
__pyx_L102_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr6__pyx_v_i);
goto __pyx_L1_error;
__pyx_L105_exit_scope:;
} /* exit inner scope */
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_30);
__pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_sum, __pyx_t_11, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 231, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_30, __pyx_v_num_mass_bals); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">232</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">chemical_potentials</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(232,0,__PYX_ERR(0, 232, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 232, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_30, __pyx_v_chemical_potentials) < 0)) __PYX_ERR(0, 232, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-28" onclick='toggleDiv(this)'>+<span class="">233</span>: <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span> <span class="o">=</span> <span class="n">candidate_phase_fracs</span></pre>
<pre class='cython code score-28 '> <span class='trace'>__Pyx_TraceLine</span>(233,0,__PYX_ERR(0, 233, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 233, __pyx_L1_error)
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_10, 0, __pyx_t_8, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_30, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_NP_values, __pyx_t_10, ((PyObject *)__pyx_v_candidate_phase_fracs)) < 0)) __PYX_ERR(0, 233, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
</pre><pre class="cython line score-28" onclick='toggleDiv(this)'>+<span class="">234</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)]]</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-28 '> <span class='trace'>__Pyx_TraceLine</span>(234,0,__PYX_ERR(0, 234, __pyx_L1_error))
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 234, __pyx_L1_error)
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(__pyx_t_30, 0, __pyx_t_8, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_X_values, __pyx_t_30, __pyx_int_0) < 0)) __PYX_ERR(0, 234, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">235</span>: <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">candidate_energy</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(235,0,__PYX_ERR(0, 235, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 235, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_GM_values, __pyx_t_30, __pyx_v_candidate_energy) < 0)) __PYX_ERR(0, 235, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">236</span>: <span class="n">var_offset</span> <span class="o">=</span> <span class="mf">0</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(236,0,__PYX_ERR(0, 236, __pyx_L1_error))
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_int_0);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_var_offset, __pyx_int_0);
</pre><pre class="cython line score-5" onclick='toggleDiv(this)'>+<span class="">237</span>: <span class="k">for</span> <span class="n">phase_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">phases</span><span class="p">)):</span></pre>
<pre class='cython code score-5 '> <span class='trace'>__Pyx_TraceLine</span>(237,0,__PYX_ERR(0, 237, __pyx_L1_error))
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_v_phases); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 237, __pyx_L1_error)
for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_8; __pyx_t_15+=1) {
__pyx_v_phase_idx = __pyx_t_15;
</pre><pre class="cython line score-48" onclick='toggleDiv(this)'>+<span class="">238</span>: <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">,</span> <span class="p">:</span><span class="n">phase_dof</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">]]]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-48 '> <span class='trace'>__Pyx_TraceLine</span>(238,0,__PYX_ERR(0, 238, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_10, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_v_phase_idx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetItemInt_List</span>(__pyx_v_phase_dof, __pyx_v_phase_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_3 = <span class='py_c_api'>PySlice_New</span>(Py_None, __pyx_t_12, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 1, __pyx_t_3);
__pyx_t_10 = 0;
__pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Y_values, __pyx_t_12, __pyx_t_30) < 0)) __PYX_ERR(0, 238, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-11" onclick='toggleDiv(this)'>+<span class="">239</span>: <span class="n">candidate_site_fracs</span><span class="p">[</span><span class="n">var_offset</span><span class="p">:</span><span class="n">var_offset</span> <span class="o">+</span> <span class="n">phase_dof</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">]]</span></pre>
<pre class='cython code score-11 '> <span class='trace'>__Pyx_TraceLine</span>(239,0,__PYX_ERR(0, 239, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetItemInt_List</span>(__pyx_v_phase_dof, __pyx_v_phase_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 239, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_11 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_v_var_offset, __pyx_t_30); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(((PyObject *)__pyx_v_candidate_site_fracs), 0, 0, &__pyx_v_var_offset, &__pyx_t_11, NULL, 0, 0, 1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 239, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-72" onclick='toggleDiv(this)'>+<span class="">240</span>: <span class="k">for</span> <span class="n">comp_idx</span><span class="p">,</span> <span class="n">comp</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="n">c</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">comps</span> <span class="k">if</span> <span class="n">c</span> <span class="o">!=</span> <span class="s">'VA'</span><span class="p">]):</span></pre>
<pre class='cython code score-72 '> <span class='trace'>__Pyx_TraceLine</span>(240,0,__PYX_ERR(0, 240, __pyx_L1_error))
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_int_0);
__pyx_t_30 = __pyx_int_0;
{ /* enter inner scope */
PyObject *__pyx_8genexpr7__pyx_v_c = NULL;
__pyx_t_12 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 240, __pyx_L112_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_comps)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_comps)) {
__pyx_t_3 = __pyx_v_comps; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3); __pyx_t_24 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_24 = -1; __pyx_t_3 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_comps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L112_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 240, __pyx_L112_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_3))) {
if (__pyx_t_24 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_3, __pyx_t_24); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_24++; if (unlikely(0 < 0)) __PYX_ERR(0, 240, __pyx_L112_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_3, __pyx_t_24); __pyx_t_24++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 240, __pyx_L112_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
} else {
if (__pyx_t_24 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_3, __pyx_t_24); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_24++; if (unlikely(0 < 0)) __PYX_ERR(0, 240, __pyx_L112_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_3, __pyx_t_24); __pyx_t_24++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 240, __pyx_L112_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
}
} else {
__pyx_t_11 = __pyx_t_9(__pyx_t_3);
if (unlikely(!__pyx_t_11)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 240, __pyx_L112_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr7__pyx_v_c, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_5 = (<span class='pyx_c_api'>__Pyx_PyUnicode_Equals</span>(__pyx_8genexpr7__pyx_v_c, __pyx_n_u_VA, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 240, __pyx_L112_error)
if (__pyx_t_5) {
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_12, (PyObject*)__pyx_8genexpr7__pyx_v_c))) __PYX_ERR(0, 240, __pyx_L112_error)
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr7__pyx_v_c);
goto __pyx_L116_exit_scope;
__pyx_L112_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr7__pyx_v_c);
goto __pyx_L1_error;
__pyx_L116_exit_scope:;
} /* exit inner scope */
__pyx_t_3 = __pyx_t_12; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3); __pyx_t_24 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
for (;;) {
if (__pyx_t_24 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_12 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_3, __pyx_t_24); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12); __pyx_t_24++; if (unlikely(0 < 0)) __PYX_ERR(0, 240, __pyx_L1_error)
#else
__pyx_t_12 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_3, __pyx_t_24); __pyx_t_24++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 240, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
#endif
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_comp, __pyx_t_12);
__pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_comp_idx, __pyx_t_30);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyInt_AddObjC</span>(__pyx_t_30, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 240, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30);
__pyx_t_30 = __pyx_t_12;
__pyx_t_12 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(240,0,__PYX_ERR(0, 240, __pyx_L1_error))
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-41" onclick='toggleDiv(this)'>+<span class="">241</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">index_exp</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">,</span> <span class="n">comp_idx</span><span class="p">]]</span> <span class="o">=</span> \</pre>
<pre class='cython code score-41 '> <span class='trace'>__Pyx_TraceLine</span>(241,0,__PYX_ERR(0, 241, __pyx_L1_error))
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
__pyx_t_32 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_10 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_32, __pyx_n_s_index_exp); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_v_phase_idx); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comp_idx);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comp_idx);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1, __pyx_v_comp_idx);
__pyx_t_32 = 0;
__pyx_t_32 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_2, __pyx_t_32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_X_values, __pyx_t_11, __pyx_t_12) < 0)) __PYX_ERR(0, 241, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
</pre><pre class="cython line score-16" onclick='toggleDiv(this)'>+<span class="">242</span>: <span class="n">mole_fractions</span><span class="p">[(</span><span class="n">phases</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">],</span> <span class="n">comp</span><span class="p">)][</span><span class="mf">0</span><span class="p">](</span></pre>
<pre class='cython code score-16 '> <span class='trace'>__Pyx_TraceLine</span>(242,0,__PYX_ERR(0, 242, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetItemInt</span>(__pyx_v_phases, __pyx_v_phase_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_comp);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_comp);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 1, __pyx_v_comp);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyDict_GetItem</span>(__pyx_v_mole_fractions, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = <span class='pyx_c_api'>__Pyx_GetItemInt</span>(__pyx_t_11, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-56" onclick='toggleDiv(this)'>+<span class="">243</span>: <span class="p">[</span><span class="n">candidate_site_fracs</span><span class="p">[</span><span class="n">var_offset</span><span class="p">:</span><span class="n">var_offset</span> <span class="o">+</span> <span class="n">phase_dof</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">]]])</span></pre>
<pre class='cython code score-56 '> <span class='trace'>__Pyx_TraceLine</span>(243,0,__PYX_ERR(0, 243, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetItemInt_List</span>(__pyx_v_phase_dof, __pyx_v_phase_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_10 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_v_var_offset, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 243, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(((PyObject *)__pyx_v_candidate_site_fracs), 0, 0, &__pyx_v_var_offset, &__pyx_t_10, NULL, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = <span class='py_c_api'>PyList_New</span>(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 243, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyList_SET_ITEM</span>(__pyx_t_10, 0, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_2))) {
__pyx_t_11 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_2);
if (likely(__pyx_t_11)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_2, function);
}
}
if (!__pyx_t_11) {
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_2)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_10); __pyx_t_10 = 0;
} else
#endif
{
__pyx_t_32 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0, __pyx_t_11); __pyx_t_11 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_10);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_32, 0+1, __pyx_t_10);
__pyx_t_10 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_32, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
</pre><pre class="cython line score-9" onclick='toggleDiv(this)'>+<span class="">244</span>: <span class="n">var_offset</span> <span class="o">+=</span> <span class="n">phase_dof</span><span class="p">[</span><span class="n">phase_idx</span><span class="p">]</span></pre>
<pre class='cython code score-9 '> <span class='trace'>__Pyx_TraceLine</span>(244,0,__PYX_ERR(0, 244, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetItemInt_List</span>(__pyx_v_phase_dof, __pyx_v_phase_idx, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 244, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_3 = <span class='py_c_api'>PyNumber_InPlaceAdd</span>(__pyx_v_var_offset, __pyx_t_30); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_var_offset, __pyx_t_3);
__pyx_t_3 = 0;
}
</pre><pre class="cython line score-0"> <span class="">245</span>: </pre>
<pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">246</span>: <span class="n">properties</span><span class="o">.</span><span class="n">attrs</span><span class="p">[</span><span class="s">'solve_iterations'</span><span class="p">]</span> <span class="o">+=</span> <span class="mf">1</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(246,0,__PYX_ERR(0, 246, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_properties, __pyx_n_s_attrs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_n_u_solve_iterations);
__pyx_t_45 = __pyx_n_u_solve_iterations;
__pyx_t_30 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_3, __pyx_t_45); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 246, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyInt_AddObjC</span>(__pyx_t_30, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 246, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_t_3, __pyx_t_45, __pyx_t_12) < 0)) __PYX_ERR(0, 246, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_45); __pyx_t_45 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-52" onclick='toggleDiv(this)'>+<span class="">247</span>: <span class="n">total_comp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">][</span><span class="o">...</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">newaxis</span><span class="p">]</span> <span class="o">*</span> \</pre>
<pre class='cython code score-52 '> <span class='trace'>__Pyx_TraceLine</span>(247,0,__PYX_ERR(0, 247, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nansum); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_NP_values, __pyx_t_3); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_Ellipsis);
<span class='refnanny'>__Pyx_GIVEREF</span>(Py_Ellipsis);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, Py_Ellipsis);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_30, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(247,0,__PYX_ERR(0, 247, __pyx_L1_error))
__pyx_t_3 = <span class='py_c_api'>PyNumber_Multiply</span>(__pyx_t_11, __pyx_t_30); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_3);
__pyx_t_3 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(247,0,__PYX_ERR(0, 247, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_t_30, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 247, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_total_comp, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-18" onclick='toggleDiv(this)'>+<span class="">248</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">],</span> <span class="n">axis</span><span class="o">=-</span><span class="mf">2</span><span class="p">)</span></pre>
<pre class='cython code score-18 '> <span class='trace'>__Pyx_TraceLine</span>(248,0,__PYX_ERR(0, 248, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_X_values, __pyx_t_3); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 248, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(248,0,__PYX_ERR(0, 248, __pyx_L1_error))
__pyx_t_3 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_3, __pyx_n_s_axis, __pyx_int_neg_2) < 0) __PYX_ERR(0, 248, __pyx_L1_error)
</pre><pre class="cython line score-39" onclick='toggleDiv(this)'>+<span class="">249</span>: <span class="n">driving_force</span> <span class="o">=</span> <span class="p">(</span><span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">*</span> <span class="n">total_comp</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=-</span><span class="mf">1</span><span class="p">)</span> <span class="o">-</span> \</pre>
<pre class='cython code score-39 '> <span class='trace'>__Pyx_TraceLine</span>(249,0,__PYX_ERR(0, 249, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_MU_values, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Multiply</span>(__pyx_t_3, __pyx_v_total_comp); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyDict_New</span>(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_11, __pyx_n_s_axis, __pyx_int_neg_1) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_empty_tuple, __pyx_t_11); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(249,0,__PYX_ERR(0, 249, __pyx_L1_error))
__pyx_t_11 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_30, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_driving_force, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">250</span>: <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(250,0,__PYX_ERR(0, 250, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 250, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_GM_values, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-43" onclick='toggleDiv(this)'>+<span class="">251</span>: <span class="n">driving_force</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">squeeze</span><span class="p">(</span><span class="n">driving_force</span><span class="p">)</span></pre>
<pre class='cython code score-43 '> <span class='trace'>__Pyx_TraceLine</span>(251,0,__PYX_ERR(0, 251, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_30))) {
__pyx_t_3 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_30);
if (likely(__pyx_t_3)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_30, function);
}
}
if (!__pyx_t_3) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_30, __pyx_v_driving_force); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_driving_force};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_30)) {
PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_driving_force};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_30, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_driving_force);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_driving_force);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+1, __pyx_v_driving_force);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_30, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_driving_force, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">252</span>: <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(252,0,__PYX_ERR(0, 252, __pyx_L1_error))
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_verbose); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 252, __pyx_L1_error)
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-26" onclick='toggleDiv(this)'>+<span class="">253</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Chem pot progress'</span><span class="p">,</span> <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">-</span> <span class="n">old_chem_pots</span><span class="p">)</span></pre>
<pre class='cython code score-26 '> <span class='trace'>__Pyx_TraceLine</span>(253,0,__PYX_ERR(0, 253, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 253, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_30 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_MU_values, __pyx_t_11); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 253, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_30, __pyx_v_old_chem_pots); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 253, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 253, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_Chem_pot_progress);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_Chem_pot_progress);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_kp_u_Chem_pot_progress);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_30, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 253, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-26" onclick='toggleDiv(this)'>+<span class="">254</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Energy progress'</span><span class="p">,</span> <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">-</span> <span class="n">old_energy</span><span class="p">)</span></pre>
<pre class='cython code score-26 '> <span class='trace'>__Pyx_TraceLine</span>(254,0,__PYX_ERR(0, 254, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 254, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_30 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_GM_values, __pyx_t_11); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 254, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_30, __pyx_v_old_energy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 254, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 254, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_Energy_progress);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_Energy_progress);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_kp_u_Energy_progress);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 1, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_30, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 254, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-13" onclick='toggleDiv(this)'>+<span class="">255</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Driving force'</span><span class="p">,</span> <span class="n">driving_force</span><span class="p">)</span></pre>
<pre class='cython code score-13 '> <span class='trace'>__Pyx_TraceLine</span>(255,0,__PYX_ERR(0, 255, __pyx_L1_error))
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 255, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_kp_u_Driving_force);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_kp_u_Driving_force);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_kp_u_Driving_force);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_driving_force);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_driving_force);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 1, __pyx_v_driving_force);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_11, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 255, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-84" onclick='toggleDiv(this)'>+<span class="">256</span>: <span class="n">no_progress</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">-</span> <span class="n">old_chem_pots</span><span class="p">)</span><span class="o">.</span><span class="n">max</span><span class="p">()</span> <span class="o"><</span> <span class="mf">0.01</span></pre>
<pre class='cython code score-84 '> <span class='trace'>__Pyx_TraceLine</span>(256,0,__PYX_ERR(0, 256, __pyx_L1_error))
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_abs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_32 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_MU_values, __pyx_t_12); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_32, __pyx_v_old_chem_pots); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
__pyx_t_32 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_32 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_32)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_32);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_32) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, __pyx_t_12};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_32, __pyx_t_12};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_32); __pyx_t_32 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else
#endif
{
__pyx_t_2 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_32); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0, __pyx_t_32); __pyx_t_32 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_2, 0+1, __pyx_t_12);
__pyx_t_12 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_max); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_11 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_11)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (__pyx_t_11) {
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
} else {
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_3); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 256, __pyx_L1_error)
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_30, __pyx_float_0_01, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_v_no_progress, __pyx_t_3);
__pyx_t_3 = 0;
</pre><pre class="cython line score-74" onclick='toggleDiv(this)'>+<span class="">257</span>: <span class="n">no_progress</span> <span class="o">&=</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">-</span> <span class="n">old_energy</span><span class="p">)</span> <span class="o"><</span> <span class="n">MIN_SOLVE_ENERGY_PROGRESS</span></pre>
<pre class='cython code score-74 '> <span class='trace'>__Pyx_TraceLine</span>(257,0,__PYX_ERR(0, 257, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_30, __pyx_n_s_abs); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_v_prop_GM_values, __pyx_t_30); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='py_c_api'>PyNumber_Subtract</span>(__pyx_t_2, __pyx_v_old_energy); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_2)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (!__pyx_t_2) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_30); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_30};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_11)) {
PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_30};
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_2); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_2); __pyx_t_2 = NULL;
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+1, __pyx_t_30);
__pyx_t_30 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MIN_SOLVE_ENERGY_PROGRESS); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_12 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_3, __pyx_t_11, Py_LT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_InPlaceAnd</span>(__pyx_v_no_progress, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_no_progress, __pyx_t_11);
__pyx_t_11 = 0;
</pre><pre class="cython line score-56" onclick='toggleDiv(this)'>+<span class="">258</span>: <span class="k">if</span> <span class="n">no_progress</span> <span class="ow">and</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">driving_force</span><span class="p">)</span> <span class="o">></span> <span class="n">MAX_SOLVE_DRIVING_FORCE</span><span class="p">:</span></pre>
<pre class='cython code score-56 '> <span class='trace'>__Pyx_TraceLine</span>(258,0,__PYX_ERR(0, 258, __pyx_L1_error))
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_no_progress); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 258, __pyx_L1_error)
if (__pyx_t_6) {
} else {
__pyx_t_5 = __pyx_t_6;
goto __pyx_L119_bool_binop_done;
}
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_abs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_12) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_v_driving_force); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_driving_force};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_driving_force};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_12); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_12); __pyx_t_12 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_driving_force);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_driving_force);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0+1, __pyx_v_driving_force);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_30, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_SOLVE_DRIVING_FORCE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_11, __pyx_t_3, Py_GT); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_30); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_30); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 258, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_5 = __pyx_t_6;
__pyx_L119_bool_binop_done:;
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">259</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Driving force failed to converge: {}'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">cur_conds</span><span class="p">))</span></pre>
<pre class='cython code score-49 '> <span class='trace'>__Pyx_TraceLine</span>(259,0,__PYX_ERR(0, 259, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_kp_u_Driving_force_failed_to_converge, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_11 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_11)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_11) {
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_v_cur_conds); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_cur_conds};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_cur_conds};
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+1, __pyx_v_cur_conds);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_30);
__pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_3, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 259, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">260</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(260,0,__PYX_ERR(0, 260, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 260, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_30, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 260, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_30, __pyx_t_3) < 0)) __PYX_ERR(0, 260, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">261</span>: <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(261,0,__PYX_ERR(0, 261, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 261, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_NP_values, __pyx_t_3, __pyx_t_30) < 0)) __PYX_ERR(0, 261, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">262</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(262,0,__PYX_ERR(0, 262, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 262, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_30, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 262, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_X_values, __pyx_t_30, __pyx_t_3) < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">263</span>: <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(263,0,__PYX_ERR(0, 263, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 263, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Y_values, __pyx_t_3, __pyx_t_30) < 0)) __PYX_ERR(0, 263, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">264</span>: <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(264,0,__PYX_ERR(0, 264, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 264, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_30, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 264, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_GM_values, __pyx_t_30, __pyx_t_3) < 0)) __PYX_ERR(0, 264, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">265</span>: <span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="s">''</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(265,0,__PYX_ERR(0, 265, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_3, __pyx_kp_u__3) < 0)) __PYX_ERR(0, 265, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">266</span>: <span class="k">break</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(266,0,__PYX_ERR(0, 266, __pyx_L1_error))
goto __pyx_L31_break;
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">267</span>: <span class="k">elif</span> <span class="n">no_progress</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(267,0,__PYX_ERR(0, 267, __pyx_L1_error))
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_no_progress); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 267, __pyx_L1_error)
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">268</span>: <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(268,0,__PYX_ERR(0, 268, __pyx_L1_error))
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_verbose); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 268, __pyx_L1_error)
if (__pyx_t_5) {
/* … */
}
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">269</span>: <span class="k">print</span><span class="p">(</span><span class="s">'No progress'</span><span class="p">)</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(269,0,__PYX_ERR(0, 269, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__pyx_tuple__22 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_kp_u_No_progress); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 269, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__22);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__22);
</pre><pre class="cython line score-38" onclick='toggleDiv(this)'>+<span class="">270</span>: <span class="n">num_mass_bals</span> <span class="o">=</span> <span class="nb">len</span><span class="p">([</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">cur_conds</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'X_'</span><span class="p">)])</span> <span class="o">+</span> <span class="mf">1</span></pre>
<pre class='cython code score-38 '> <span class='trace'>__Pyx_TraceLine</span>(270,0,__PYX_ERR(0, 270, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr8__pyx_v_i = NULL;
__pyx_t_3 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_8 = 0;
if (unlikely(__pyx_v_cur_conds == Py_None)) {
<span class='py_c_api'>PyErr_Format</span>(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "keys");
__PYX_ERR(0, 270, __pyx_L124_error)
}
__pyx_t_12 = __Pyx_dict_iterator(__pyx_v_cur_conds, 0, __pyx_n_s_keys, (&__pyx_t_15), (&__pyx_t_17)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30);
__pyx_t_30 = __pyx_t_12;
__pyx_t_12 = 0;
while (1) {
__pyx_t_36 = __Pyx_dict_iter_next(__pyx_t_30, __pyx_t_15, &__pyx_t_8, &__pyx_t_12, NULL, NULL, __pyx_t_17);
if (unlikely(__pyx_t_36 == 0)) break;
if (unlikely(__pyx_t_36 == -1)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr8__pyx_v_i, __pyx_t_12);
__pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_8genexpr8__pyx_v_i, __pyx_n_s_startswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_12, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 270, __pyx_L124_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
if (__pyx_t_5) {
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_3, (PyObject*)__pyx_8genexpr8__pyx_v_i))) __PYX_ERR(0, 270, __pyx_L124_error)
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr8__pyx_v_i);
goto __pyx_L128_exit_scope;
__pyx_L124_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr8__pyx_v_i);
goto __pyx_L1_error;
__pyx_L128_exit_scope:;
} /* exit inner scope */
__pyx_t_15 = <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_3); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 270, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyInt_FromSsize_t</span>((__pyx_t_15 + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_num_mass_bals, __pyx_t_3);
__pyx_t_3 = 0;
/* … */
__pyx_tuple__23 = <span class='py_c_api'>PyTuple_Pack</span>(1, __pyx_n_u_X_2); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 270, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__23);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__23);
</pre><pre class="cython line score-92" onclick='toggleDiv(this)'>+<span class="">271</span>: <span class="n">chemical_potentials</span> <span class="o">=</span> <span class="n">l_multipliers</span><span class="p">[</span><span class="nb">sum</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sublattices</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">]):</span></pre>
<pre class='cython code score-92 '> <span class='trace'>__Pyx_TraceLine</span>(271,0,__PYX_ERR(0, 271, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_8genexpr9__pyx_v_i = NULL;
__pyx_t_3 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_30 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_30); __pyx_t_15 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_15 = -1; __pyx_t_30 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_9 = Py_TYPE(__pyx_t_30)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 271, __pyx_L131_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_30))) {
if (__pyx_t_15 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_30)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_30, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 271, __pyx_L131_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_30, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
} else {
if (__pyx_t_15 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_30)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_11 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_30, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 271, __pyx_L131_error)
#else
__pyx_t_11 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_30, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
#endif
}
} else {
__pyx_t_11 = __pyx_t_9(__pyx_t_30);
if (unlikely(!__pyx_t_11)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 271, __pyx_L131_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_8genexpr9__pyx_v_i, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_12 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_11, __pyx_8genexpr9__pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_12, __pyx_n_s_sublattices); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_11); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_3, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 271, __pyx_L131_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr9__pyx_v_i);
goto __pyx_L134_exit_scope;
__pyx_L131_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_8genexpr9__pyx_v_i);
goto __pyx_L1_error;
__pyx_L134_exit_scope:;
} /* exit inner scope */
__pyx_t_30 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 271, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_30, 0, __pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_sum, __pyx_t_30, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
/* … */
<span class='trace'>__Pyx_TraceLine</span>(271,0,__PYX_ERR(0, 271, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetSlice</span>(((PyObject *)__pyx_v_l_multipliers), 0, 0, &__pyx_t_3, &__pyx_t_11, NULL, 0, 0, 1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 271, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_v_chemical_potentials, __pyx_t_30);
__pyx_t_30 = 0;
</pre><pre class="cython line score-93" onclick='toggleDiv(this)'>+<span class="">272</span>: <span class="nb">sum</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">dbf</span><span class="o">.</span><span class="n">phases</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sublattices</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">phases</span><span class="p">])</span> <span class="o">+</span> <span class="n">num_mass_bals</span><span class="p">]</span></pre>
<pre class='cython code score-93 '> <span class='trace'>__Pyx_TraceLine</span>(272,0,__PYX_ERR(0, 272, __pyx_L1_error))
{ /* enter inner scope */
PyObject *__pyx_9genexpr10__pyx_v_i = NULL;
__pyx_t_30 = <span class='py_c_api'>PyList_New</span>(0); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_v_phases)) || <span class='py_c_api'>PyTuple_CheckExact</span>(__pyx_v_phases)) {
__pyx_t_11 = __pyx_v_phases; <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_11); __pyx_t_15 = 0;
__pyx_t_9 = NULL;
} else {
__pyx_t_15 = -1; __pyx_t_11 = <span class='py_c_api'>PyObject_GetIter</span>(__pyx_v_phases); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_9 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 272, __pyx_L137_error)
}
for (;;) {
if (likely(!__pyx_t_9)) {
if (likely(<span class='py_c_api'>PyList_CheckExact</span>(__pyx_t_11))) {
if (__pyx_t_15 >= <span class='py_macro_api'>PyList_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_12 = <span class='py_macro_api'>PyList_GET_ITEM</span>(__pyx_t_11, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 272, __pyx_L137_error)
#else
__pyx_t_12 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
#endif
} else {
if (__pyx_t_15 >= <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_t_11)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_12 = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_t_11, __pyx_t_15); <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 272, __pyx_L137_error)
#else
__pyx_t_12 = <span class='py_macro_api'>PySequence_ITEM</span>(__pyx_t_11, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
#endif
}
} else {
__pyx_t_12 = __pyx_t_9(__pyx_t_11);
if (unlikely(!__pyx_t_12)) {
PyObject* exc_type = <span class='py_c_api'>PyErr_Occurred</span>();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || <span class='py_c_api'>PyErr_GivenExceptionMatches</span>(exc_type, PyExc_StopIteration))) <span class='py_c_api'>PyErr_Clear</span>();
else __PYX_ERR(0, 272, __pyx_L137_error)
}
break;
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
}
<span class='pyx_macro_api'>__Pyx_XDECREF_SET</span>(__pyx_9genexpr10__pyx_v_i, __pyx_t_12);
__pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_dbf, __pyx_n_s_phases); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
__pyx_t_2 = <span class='py_c_api'>PyObject_GetItem</span>(__pyx_t_12, __pyx_9genexpr10__pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_2, __pyx_n_s_sublattices); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_8 = <span class='py_c_api'>PyObject_Length</span>(__pyx_t_12); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = <span class='py_c_api'>PyInt_FromSsize_t</span>(__pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
if (unlikely(<span class='pyx_c_api'>__Pyx_ListComp_Append</span>(__pyx_t_30, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 272, __pyx_L137_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_9genexpr10__pyx_v_i);
goto __pyx_L140_exit_scope;
__pyx_L137_error:;
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_9genexpr10__pyx_v_i);
goto __pyx_L1_error;
__pyx_L140_exit_scope:;
} /* exit inner scope */
__pyx_t_11 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_11, 0, __pyx_t_30);
__pyx_t_30 = 0;
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_sum, __pyx_t_11, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 272, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyNumber_Add</span>(__pyx_t_30, __pyx_v_num_mass_bals); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">273</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">chemical_potentials</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(273,0,__PYX_ERR(0, 273, __pyx_L1_error))
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 273, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_30, __pyx_v_chemical_potentials) < 0)) __PYX_ERR(0, 273, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">274</span>: <span class="k">break</span></pre>
<pre class='cython code score-0 '> <span class='trace'>__Pyx_TraceLine</span>(274,0,__PYX_ERR(0, 274, __pyx_L1_error))
goto __pyx_L31_break;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">275</span>: <span class="k">elif</span> <span class="p">(</span><span class="ow">not</span> <span class="n">no_progress</span><span class="p">)</span> <span class="ow">and</span> <span class="n">cur_iter</span> <span class="o">==</span> <span class="n">MAX_SOLVE_ITERATIONS</span><span class="o">-</span><span class="mf">1</span><span class="p">:</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(275,0,__PYX_ERR(0, 275, __pyx_L1_error))
__pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_v_no_progress); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 275, __pyx_L1_error)
__pyx_t_46 = ((!__pyx_t_6) != 0);
if (__pyx_t_46) {
} else {
__pyx_t_5 = __pyx_t_46;
goto __pyx_L141_bool_binop_done;
}
__pyx_t_30 = <span class='pyx_c_api'>__Pyx_PyInt_From_int</span>(__pyx_v_cur_iter); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 275, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_30);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_MAX_SOLVE_ITERATIONS); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 275, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyInt_SubtractObjC</span>(__pyx_t_11, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='py_c_api'>PyObject_RichCompare</span>(__pyx_t_30, __pyx_t_3, Py_EQ); <span class='refnanny'>__Pyx_XGOTREF</span>(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 275, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_46 = <span class='pyx_c_api'>__Pyx_PyObject_IsTrue</span>(__pyx_t_11); if (unlikely(__pyx_t_46 < 0)) __PYX_ERR(0, 275, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_5 = __pyx_t_46;
__pyx_L141_bool_binop_done:;
if (__pyx_t_5) {
/* … */
}
}
__pyx_L31_break:;
</pre><pre class="cython line score-49" onclick='toggleDiv(this)'>+<span class="">276</span>: <span class="k">print</span><span class="p">(</span><span class="s">'Failed to converge: {}'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">cur_conds</span><span class="p">))</span></pre>
<pre class='cython code score-49 '> <span class='trace'>__Pyx_TraceLine</span>(276,0,__PYX_ERR(0, 276, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_kp_u_Failed_to_converge, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_30 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {
__pyx_t_30 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);
if (likely(__pyx_t_30)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_30);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);
}
}
if (!__pyx_t_30) {
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_v_cur_conds); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else {
#if CYTHON_FAST_PYCALL
if (<span class='py_c_api'>PyFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_30, __pyx_v_cur_conds};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
#if CYTHON_FAST_PYCCALL
if (<span class='pyx_c_api'>__Pyx_PyFastCFunction_Check</span>(__pyx_t_3)) {
PyObject *__pyx_temp[2] = {__pyx_t_30, __pyx_v_cur_conds};
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyCFunction_FastCall</span>(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_30); __pyx_t_30 = 0;
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
} else
#endif
{
__pyx_t_12 = <span class='py_c_api'>PyTuple_New</span>(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_12);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_30); <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0, __pyx_t_30); __pyx_t_30 = NULL;
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_cur_conds);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_v_cur_conds);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_12, 0+1, __pyx_v_cur_conds);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
}
}
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_11);
<span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_11);
__pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_builtin_print, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">277</span>: <span class="n">prop_MU_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(277,0,__PYX_ERR(0, 277, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 277, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 277, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_MU_values, __pyx_t_11, __pyx_t_3) < 0)) __PYX_ERR(0, 277, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">278</span>: <span class="n">prop_NP_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(278,0,__PYX_ERR(0, 278, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 278, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_NP_values, __pyx_t_3, __pyx_t_11) < 0)) __PYX_ERR(0, 278, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">279</span>: <span class="n">prop_X_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(279,0,__PYX_ERR(0, 279, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_X_values, __pyx_t_11, __pyx_t_3) < 0)) __PYX_ERR(0, 279, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">280</span>: <span class="n">prop_Y_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(280,0,__PYX_ERR(0, 280, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Y_values, __pyx_t_3, __pyx_t_11) < 0)) __PYX_ERR(0, 280, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
</pre><pre class="cython line score-14" onclick='toggleDiv(this)'>+<span class="">281</span>: <span class="n">prop_GM_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span></pre>
<pre class='cython code score-14 '> <span class='trace'>__Pyx_TraceLine</span>(281,0,__PYX_ERR(0, 281, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_11, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_GM_values, __pyx_t_11, __pyx_t_3) < 0)) __PYX_ERR(0, 281, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">282</span>: <span class="n">prop_Phase_values</span><span class="p">[</span><span class="n">it</span><span class="o">.</span><span class="n">multi_index</span><span class="p">]</span> <span class="o">=</span> <span class="s">''</span></pre>
<pre class='cython code score-8 '> <span class='trace'>__Pyx_TraceLine</span>(282,0,__PYX_ERR(0, 282, __pyx_L1_error))
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_multi_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
if (unlikely(<span class='py_c_api'>PyObject_SetItem</span>(__pyx_v_prop_Phase_values, __pyx_t_3, __pyx_kp_u__3) < 0)) __PYX_ERR(0, 282, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
</pre><pre class="cython line score-19" onclick='toggleDiv(this)'>+<span class="">283</span>: <span class="n">it</span><span class="o">.</span><span class="n">iternext</span><span class="p">()</span></pre>
<pre class='cython code score-19 '> <span class='trace'>__Pyx_TraceLine</span>(283,0,__PYX_ERR(0, 283, __pyx_L1_error))
__pyx_t_11 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_v_it, __pyx_n_s_iternext); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 283, __pyx_L1_error)
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_11);
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && likely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_11))) {
__pyx_t_12 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_11);
if (likely(__pyx_t_12)) {
PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_11);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_12);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(function);
<span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_11, function);
}
}
if (__pyx_t_12) {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_12); __pyx_t_12 = 0;
} else {
__pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
}
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_11); __pyx_t_11 = 0;
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;
__pyx_L3_continue:;
}
</pre><pre class="cython line score-2" onclick='toggleDiv(this)'>+<span class="">284</span>: <span class="k">return</span> <span class="n">properties</span></pre>
<pre class='cython code score-2 '> <span class='trace'>__Pyx_TraceLine</span>(284,0,__PYX_ERR(0, 284, __pyx_L1_error))
<span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);
<span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_v_properties);
__pyx_r = __pyx_v_properties;
goto __pyx_L0;
</pre></div></body></html>
```python
%lprun -f _solve_eq_at_conditions equilibrium(dbf, ['AL', 'FE', 'VA'], list(dbf.phases.keys()), {v.T: 700, v.X('AL'): (0,1,0.02), v.P: 101325}, model=models, solve_eq_at_conditions=_solve_eq_at_conditions)
```
```python
```
|
{"hexsha": "9b9edb92a41123cdf5c658be1aaf878ab40cdfde", "size": 806655, "ext": "ipynb", "lang": "Jupyter Notebook", "max_stars_repo_path": "EqPerformance-solveq.ipynb", "max_stars_repo_name": "richardotis/pycalphad-sandbox", "max_stars_repo_head_hexsha": "43d8786eee8f279266497e9c5f4630d19c893092", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-03-08T18:21:30.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-08T18:21:30.000Z", "max_issues_repo_path": "EqPerformance-solveq.ipynb", "max_issues_repo_name": "richardotis/pycalphad-sandbox", "max_issues_repo_head_hexsha": "43d8786eee8f279266497e9c5f4630d19c893092", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EqPerformance-solveq.ipynb", "max_forks_repo_name": "richardotis/pycalphad-sandbox", "max_forks_repo_head_hexsha": "43d8786eee8f279266497e9c5f4630d19c893092", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-03T01:31:57.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-03T01:31:57.000Z", "avg_line_length": 98.6613258317, "max_line_length": 1703, "alphanum_fraction": 0.6108237103, "converted": true, "num_tokens": 244089}
|
import matplotlib.pyplot as plt
import numpy as np
from typing import List
def bits_to_int_list(bits: str) -> List[int]:
"""
Ex:
1010100 -> [1, 0, 1, 0, 1, 0, 0]
"""
bits = list(map(int, bits))
return bits
def make_graph(signal: List[int], bits: List[int], title: str) -> None:
"""Uses matplotlib.pyplot step method to make signal representation"""
# horizontal lines
features = {'color': 'gray', 'linewidth': 0.4}
plt.axhline(y=0, **features)
bits = ["phase"] + bits
print(len(bits), len(signal))
# vertical lines
ratio = len(signal)//len(bits)
vertical_lines_coordinates = np.arange(0, len(signal), ratio)
for x_pos in vertical_lines_coordinates:
plt.axvline(x=x_pos, **features)
# axis
plt.xticks(vertical_lines_coordinates[:-1]+0.5*ratio, bits)
plt.yticks([0], [0])
x_coordinates = list(range(len(signal)))
plt.step(x_coordinates, signal, where='pre', color='red')
# scale
limit = 3
plt.ylim(bottom=-limit, top=limit)
plt.title(title)
plt.show()
def manchester(bits: str, convention: str = "thomas") -> None:
"""Plots the graphical representation of the signal with the manchester
encoding, can use both Thomas or IEEE convention"""
bits = bits_to_int_list(bits)
up_transition = [-1, 1]
down_transition = [1, -1]
if convention == 'thomas':
one, zero = down_transition, up_transition
elif convention == "ieee":
one, zero = up_transition, down_transition
else:
raise ValueError(f"Convention {convention} does not exist")
signal = []
for bit in bits:
if bit:
signal += one
else:
signal += zero
signal = [0]*3 + signal
make_graph(signal, bits, f"{convention.upper()} Manchester Representation")
def d_manchester(bits: str, initial_state=-1) -> None:
"""Plots the graphical representation of the signal with the differential
manchester encoding"""
bits = bits_to_int_list(bits)
signal = []
phase = initial_state
for bit in bits:
if bit:
signal.append(phase)
phase *= -1
signal.append(phase)
else:
signal.append(phase * -1)
signal.append(phase)
signal = [initial_state]*3 + signal
title = "Differential Manchester Representation"
make_graph(signal, bits, title)
def b8zs(bits: str, initial_state: int = -1) -> None:
"""Plots the graphical representation of the signal with the binary eight
zero suppress encodings, can change the initial phase to 0 or 1"""
bits = bits_to_int_list(bits)
signal = []
phase = initial_state
count_zero = 0
for bit in bits:
if bit == 1:
phase *= -1
signal.append(phase)
count_zero = 0
elif bit == 0:
signal.append(0)
count_zero += 1
if count_zero == 8:
signal[-5:] = [phase, phase*-1, 0, phase*-1, phase]
count_zero = 0
signal = [initial_state]*2 + signal
title = "B8ZS representation"
make_graph(signal, bits, title)
def is_even(number: int):
"""Return True if the number is even and false otherwise"""
return number % 2 == 0
def four_zeros_substitution(count_pulses: int, phase: int) -> List[int]:
"""returns the modified values based on the table rule of hdb3"""
count_pulses_even = (count_pulses % 2 == 0)
state_positive = (phase == 1)
if count_pulses_even and state_positive:
modified = [-1, 0, 0, -1]
elif count_pulses_even and not state_positive:
modified = [1, 0, 0, 1]
elif not count_pulses_even and state_positive:
modified = [0, 0, 0, 1]
else:
modified = [0, 0, 0, -1]
return modified
def hdb3(bits: str, initial_state: int) -> None:
"""Plots the graphical representation of the signal with the HDB3 encoding,
can change the initial phase to 0 or 1"""
bits = bits_to_int_list(bits)
signal = []
phase = initial_state
count_zero = 0
count_pulses = 1 # because of phase
for bit in bits:
if bit == 1:
phase *= -1
signal.append(phase)
count_pulses += 1
count_zero = 0
elif bit == 0:
count_zero += 1
signal.append(0)
if count_zero == 4:
signal[-4:] = four_zeros_substitution(count_pulses, phase)
phase = signal[-1]
count_pulses = 0
count_zero = 0
signal = [initial_state]*2 + signal
title = "HDB3 Representation"
make_graph(signal, bits, title)
|
{"hexsha": "945432d729e002edb16c7d46be99ec4d9f1c4ac5", "size": 4701, "ext": "py", "lang": "Python", "max_stars_repo_path": "bits_to_plot.py", "max_stars_repo_name": "renan-cunha/signal_encoding", "max_stars_repo_head_hexsha": "16ae675fb6575f13219f44dc15c2eb1c84069632", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-23T23:55:33.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-23T23:55:33.000Z", "max_issues_repo_path": "bits_to_plot.py", "max_issues_repo_name": "renan-cunha/signal_encoding", "max_issues_repo_head_hexsha": "16ae675fb6575f13219f44dc15c2eb1c84069632", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bits_to_plot.py", "max_forks_repo_name": "renan-cunha/signal_encoding", "max_forks_repo_head_hexsha": "16ae675fb6575f13219f44dc15c2eb1c84069632", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0172413793, "max_line_length": 79, "alphanum_fraction": 0.5996596469, "include": true, "reason": "import numpy", "num_tokens": 1207}
|
module TestPatterns
using Test
using ReTest: and, or, not, interpolated, reachable, depth, pass, fail, iter
import ReTest
struct MockTestset
id
marks
parent
iter
MockTestset() = new(rand(1:typemax(Int)), ReTest.Marks(), nothing, 1)
end
ReTest.tsdepth(::MockTestset) = 1
const basic_patterns = [and(), or(), not(0), interpolated, 0, r"", :label,
depth(2), pass, fail, iter(1)]
VERSION >= v"1.3" && push!(basic_patterns, reachable(1))
@testset "patterns: ==" begin
for a = basic_patterns, b = basic_patterns
if a === b
@test a == b
if !(a isa Regex || a isa Integer || a isa Symbol)
@test -a == not(a)
end
else
@test a != b
for f in (and, or)
@test f(a) == f(a)
@test f(a) == f(deepcopy(a))
@test f(a) != f(b)
@test f(a, b) == f(a, b)
@test f(a, b) == f(deepcopy(a), deepcopy(b))
@test f(a, b) != f(b, a)
@test f(and(a, b), or(b, a)) == f(and(a, b), or(b, a))
@test f(and(a, b), or(a, b)) != f(and(a, b), or(b, a))
@test f(not(a), and(a, b)) == f(not(a), and(a, b))
@test f(and(a, b), not(a)) != f(not(a), and(a, b))
@test f(not(a), r"a", and(a, b)) == f(not(a), r"a", and(a, b))
@test f(not(a), r"a", and(a, b)) != f(not(a), r"b", and(a, b))
end
@test not(a) == not(a)
@test not(a) == not(deepcopy(a))
@test not(a) != not(b)
@test not(not(a)) == not(deepcopy(not(a)))
if VERSION >= v"1.3"
@test reachable(a) == reachable(a)
@test reachable(a) == reachable(deepcopy(a))
@test reachable(a) != reachable(b)
@test reachable(reachable(a)) == reachable(deepcopy(reachable(a)))
end
end
end
end
@testset "patterns: interface" begin
for a in basic_patterns
@test ReTest.matches(a, "a", MockTestset()) isa Union{Missing, Bool}
@test ReTest.matches(a, missing, MockTestset()) isa Union{Missing, Bool}
@test ReTest.alwaysmatches(a, 1) isa Bool
@test ReTest.has(a, Integer) isa Bool
@test ReTest.has(a, ReTest.Iter) isa Bool
end
end
@testset "patterns: not" begin
pats = [or(1, 3), and(1, r"a"), not(1), interpolated, depth(3)]
VERSION >= v"1.3" && push!(pats, reachable("c"))
for p ∈ pats
@test -p == not(p)
end
end
end # TestPatterns
|
{"hexsha": "dc7cc65bf92f4deda0706c2353117b0dfe7f70c6", "size": 2595, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/test_patterns.jl", "max_stars_repo_name": "danielsoutar/ReTest.jl", "max_stars_repo_head_hexsha": "4831b0fc23f2897bbeb999de9bdd14e968653199", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 82, "max_stars_repo_stars_event_min_datetime": "2020-11-04T22:33:36.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T13:37:31.000Z", "max_issues_repo_path": "test/test_patterns.jl", "max_issues_repo_name": "rfourquet/InlineTest", "max_issues_repo_head_hexsha": "4831b0fc23f2897bbeb999de9bdd14e968653199", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 24, "max_issues_repo_issues_event_min_datetime": "2020-11-05T20:31:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T16:02:16.000Z", "max_forks_repo_path": "test/test_patterns.jl", "max_forks_repo_name": "rfourquet/InlineTest", "max_forks_repo_head_hexsha": "4831b0fc23f2897bbeb999de9bdd14e968653199", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-04-14T23:41:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-07T18:48:54.000Z", "avg_line_length": 33.2692307692, "max_line_length": 82, "alphanum_fraction": 0.4894026975, "num_tokens": 768}
|
program t
integer::ierr,i
character(5)::s
100 format (i0)
open(unit=77,file='infile',status='old',iostat=ierr)
read(77,fmt='(a)',iostat=ierr) s
print 100,ierr
print '(a)',s
close(77,iostat=ierr)
end program t
|
{"hexsha": "fdb1879ff0f73c9226e85d66f2cffb282e7c744a", "size": 223, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "tests/t0180r/t.f90", "max_stars_repo_name": "maddenp/ppp", "max_stars_repo_head_hexsha": "81956c0fc66ff742531817ac9028c4df940cc13e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-08-13T16:32:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-21T12:37:58.000Z", "max_issues_repo_path": "tests/t0180r/t.f90", "max_issues_repo_name": "maddenp/ppp", "max_issues_repo_head_hexsha": "81956c0fc66ff742531817ac9028c4df940cc13e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/t0180r/t.f90", "max_forks_repo_name": "maddenp/ppp", "max_forks_repo_head_hexsha": "81956c0fc66ff742531817ac9028c4df940cc13e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-07-30T17:02:27.000Z", "max_forks_repo_forks_event_max_datetime": "2015-08-03T16:29:41.000Z", "avg_line_length": 20.2727272727, "max_line_length": 54, "alphanum_fraction": 0.668161435, "num_tokens": 88}
|
import numpy as np
import fastfilters as ff
import vigra
import time
class Timer(object):
def __enter__(self):
self.a = time.clock()
return self
def __exit__(self, *args):
self.b = time.clock()
self.delta = self.b - self.a
a = np.zeros((5000,5000)).astype(np.float32)
for order in [0,1,2]:
for sigma in [1,2,3,4,5,6,7,8,9,10]:
with Timer() as tvigra:
resvigra = vigra.filters.gaussianDerivative(a, sigma, [order, order])
with Timer() as tff:
resff = ff.gaussianDerivative(a, sigma, [order, order])
fact = tvigra.delta / tff.delta
print("Timing gaussian 2D with order = %d and sigma = %d: vigra = %f, ff = %f --> speedup: %f" % (order, sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5,6,7,8,9,10]:
with Timer() as tvigra:
resvigra = vigra.filters.gaussianGradientMagnitude(a, sigma)
with Timer() as tff:
resff = ff.gaussianGradientMagnitude(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing gradient magnitude 2D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5,6,7,8,9,10]:
with Timer() as tvigra:
resvigra = vigra.filters.laplacianOfGaussian(a, sigma)
with Timer() as tff:
resff = ff.laplacianOfGaussian(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing laplacian 2D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5,6,7,8,9,10]:
with Timer() as tvigra:
resvigra = vigra.filters.hessianOfGaussianEigenvalues(a, sigma)
with Timer() as tff:
resff = ff.hessianOfGaussianEigenvalues(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing HOG 2D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5,6,7,8,9,10]:
sigma2 = 2*sigma
with Timer() as tvigra:
resvigra = vigra.filters.structureTensorEigenvalues(a, sigma, sigma2)
with Timer() as tff:
resff = ff.structureTensorEigenvalues(a, sigma, sigma2)
fact = tvigra.delta / tff.delta
print("Timing ST 2D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
a = np.zeros((100,100,100)).astype(np.float32)
for order in [0,1,2]:
for sigma in [1,2,3,4,5]:
with Timer() as tvigra:
resvigra = vigra.filters.gaussianDerivative(a, sigma, [order, order, order])
with Timer() as tff:
resff = ff.gaussianDerivative(a, sigma, [order, order, order])
fact = tvigra.delta / tff.delta
print("Timing gaussian 3D with order = %d and sigma = %d: vigra = %f, ff = %f --> speedup: %f" % (order, sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5]:
with Timer() as tvigra:
resvigra = vigra.filters.gaussianGradientMagnitude(a, sigma)
with Timer() as tff:
resff = ff.gaussianGradientMagnitude(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing gradient magnitude 3D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5]:
with Timer() as tvigra:
resvigra = vigra.filters.laplacianOfGaussian(a, sigma)
with Timer() as tff:
resff = ff.laplacianOfGaussian(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing laplacian 3D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5]:
with Timer() as tvigra:
resvigra = vigra.filters.hessianOfGaussianEigenvalues(a, sigma)
with Timer() as tff:
resff = ff.hessianOfGaussianEigenvalues(a, sigma)
fact = tvigra.delta / tff.delta
print("Timing HOG 3D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
for sigma in [1,2,3,4,5]:
sigma2 = 2*sigma
with Timer() as tvigra:
resvigra = vigra.filters.structureTensorEigenvalues(a, sigma, sigma2)
with Timer() as tff:
resff = ff.structureTensorEigenvalues(a, sigma, sigma2)
fact = tvigra.delta / tff.delta
print("Timing ST 3D with sigma = %f: vigra = %f, ff = %f --> speedup: %f" % (sigma, tvigra.delta, tff.delta, fact))
|
{"hexsha": "914c2c5928fe6cc64f0b23915b391e57e2e59696", "size": 4099, "ext": "py", "lang": "Python", "max_stars_repo_path": "benchmark/bench_vigra.py", "max_stars_repo_name": "k-dominik/fastfilters", "max_stars_repo_head_hexsha": "715281e8ee20e15080e416b60e13e1d33984908f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2016-06-13T13:48:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-30T06:49:43.000Z", "max_issues_repo_path": "benchmark/bench_vigra.py", "max_issues_repo_name": "hci-unihd/fastfilters", "max_issues_repo_head_hexsha": "715281e8ee20e15080e416b60e13e1d33984908f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2016-06-14T22:00:05.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-05T12:12:24.000Z", "max_forks_repo_path": "benchmark/bench_vigra.py", "max_forks_repo_name": "hci-unihd/fastfilters", "max_forks_repo_head_hexsha": "715281e8ee20e15080e416b60e13e1d33984908f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 10, "max_forks_repo_forks_event_min_datetime": "2016-06-13T19:55:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-28T06:43:28.000Z", "avg_line_length": 29.4892086331, "max_line_length": 146, "alphanum_fraction": 0.6616247865, "include": true, "reason": "import numpy", "num_tokens": 1460}
|
"""
@author: Torben Gräber
"""
# Imports
import numpy as np
import matplotlib.pyplot as plt
import GPyOpt
# Keras and Tensorflow Imports
from keras.callbacks import ModelCheckpoint
# Custom Imports
from .HelperFunctions import ensure_dir, get_color_setup
from .HelperFunctions import save_pickle_file, load_pickle_file
# Function and Class Definitions
class SPModelTrainer():
'''
Training Process
Hyperparameter Optimization with GPyOpt
Fit, Error and other Evaluation Plots
'''
def __init__(self, SPModel, SPDataset, name=None):
self.name = name
self.SPModel = SPModel
self.SPDataset = SPDataset
self.training_history = SPTrainingHistory()
def save_training_history(self, savename=None):
savename = savename if savename else self.name + '/' + 'SPOptHist.pkl'
savelist = [self.training_history]
save_pickle_file(savename, savelist)
def load_training_history(self, savename=None):
savename = savename if savename else self.name + '/' + 'SPOptHist.pkl'
[self.training_history] = load_pickle_file(savename)
def fit_model(self,timesteps=None,shift=None,batch_size=None,set_measurement_transition_invalid=False,discard_invalid=False,**fit_args):
# Get Training Data
X_train, Y_train, I_train = self.SPDataset.get_3D_data(dataset='train',
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
timesteps=timesteps,
shift=shift,
set_measurement_transition_invalid=set_measurement_transition_invalid,
seq2seq_prediction=self.SPModel.seq2seq_prediction,
discard_invalid=discard_invalid)
# Get Validation Data
validation_data = None
if self.SPDataset.X_val is not(None):
X_val, Y_val, I_val = self.SPDataset.get_3D_data(dataset='val',
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
timesteps=timesteps,
shift=shift,
seq2seq_prediction=self.SPModel.seq2seq_prediction,
discard_invalid=discard_invalid)
validation_data = [[*X_val,*I_val],[*Y_val]]
# Fit Model
if self.SPModel.num_gpus is not(None):
new_history = self.SPModel.models_gpu[0].fit([*X_train,*I_train],[*Y_train],
validation_data=validation_data,
batch_size=batch_size,
**self.SPModel.additional_fit_args,**fit_args).history
else:
new_history = self.SPModel.models[0].fit([*X_train,*I_train],[*Y_train],
validation_data=validation_data,
batch_size=batch_size,
**self.SPModel.additional_fit_args,**fit_args).history
# Append History
self.training_history._append_history(new_history)
def fit_model_generator(self,timesteps=None,batch_size=None,set_measurement_transition_invalid=False,**fit_generator_args):
# Get Training Generator
spgenerator = self.SPDataset.get_timeseries_generator(timesteps,batch_size,
dataset='train',
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
seq2seq_prediction=self.SPModel.seq2seq_prediction)
spgenerator_val = self.SPDataset.get_timeseries_generator(timesteps,
batch_size,dataset='val',
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
seq2seq_prediction=self.SPModel.seq2seq_prediction)
# Fit Model
if self.SPModel.num_gpus is not(None):
new_history = self.SPModel.models_gpu[0].fit_generator(generator=spgenerator,
validation_data=spgenerator_val,
**self.SPModel.additional_fit_args,
**fit_generator_args).history
else:
new_history = self.SPModel.models[0].fit_generator(generator=spgenerator,
validation_data=spgenerator_val,
**self.SPModel.additional_fit_args,
**fit_generator_args).history
# Append History
self.training_history._append_history(new_history)
def _export_fit_to_mat(self,y_true,y_pred):
print('Not implemented yet.')
def show_fit(self,model=0,dataset='val',output_tensors='all',timesteps=None,downsample=1,unscale_data=False,indices=None,export_fit=False,zero_inval_Y=False):
# Check Inputs
matching_timesteps_for_seq2seq = timesteps or self.SPModel.seq2seq_prediction
assert matching_timesteps_for_seq2seq
# Get Data
X, Y, I = self.SPDataset.get_3D_data(dataset=dataset,
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
timesteps=timesteps,
shift=1,
indices=indices,
seq2seq_prediction=self.SPModel.seq2seq_prediction,
zero_inval_Y=zero_inval_Y)
# All Valid for Vizualization
I = [np.ones_like(I[0])] if not(zero_inval_Y) else I
# Predict
print('Predicting ...')
if model==0:
y_pred = self.SPModel.predict([*X,*I])
elif model==1:
y_pred = self.SPModel.predict([*X],submodel=model)
else:
raise ValueError('Only model == 1 or model == 0 supported.')
# Unscale Prediction
if unscale_data and self.SPModel.request_scaled_Y:
Y = self.SPDataset._unscale_Y(Y)
y_pred = self.SPDataset._unscale_Y(y_pred)
# Output Tensors
if output_tensors=='all':
output_tensors=np.arange(0,len(y_pred))
# Export Fit
if export_fit:
self._export_fit_to_mat(y_true=Y,y_pred=y_pred)
# Plot
print('Plotting ...')
for i_Y in output_tensors:
# Plot
dt = self.SPDataset.dt
if self.SPDataset.dt is None:
dt = 1
if dataset == 'train':
n = self.SPDataset.n_train
elif dataset == 'val':
n = self.SPDataset.n_val
elif dataset == 'test':
n = self.SPDataset.n_test
else:
print('Invalid data set choice.')
Y_curr = Y[i_Y]#np.concatenate([*Y],axis=2)
y_pred_curr = y_pred[i_Y]
Y_signal_names = []
for name in self.SPDataset.Y_signal_names:
Y_signal_names = Y_signal_names + name
plt.figure()
sp = plt.subplot(Y_curr.shape[2],1,1)
for i in range(Y_curr.shape[2]):
if i>0:
plt.subplot(Y_curr.shape[2],1,i+1,sharex=sp)
if timesteps is None:
t = np.arange(0,np.int(np.ceil(n/downsample)))*dt*downsample
plt.plot(t,Y_curr[0,::downsample,i],label=Y_signal_names[i])
plt.plot(t,y_pred_curr[0,::downsample,i])
else:
t = np.arange(0,np.int(np.ceil(Y_curr.shape[0]/downsample)))*dt*downsample
plt.plot(t,Y_curr[::downsample,-1,i],label=Y_signal_names[i])
plt.plot(t,y_pred_curr[::downsample,-1,i],label='estimate')
plt.ylabel('Output')
if self.SPDataset.Y_signal_names is not(None):
plt.legend()
if self.SPDataset.dt is not(None):
plt.xlabel('Time t [s]')
else:
plt.xlabel('Timestep k')
plt.title('Fit Plot - Data Set: ' + dataset)
plt.grid()
def show_error_plot(self,dataset='val',output_tensors='all',timesteps=None,downsample=1,unscale_data=False,indices=None):
# Check Inputs
matching_timesteps_for_seq2seq = timesteps or self.SPModel.seq2seq_prediction
assert matching_timesteps_for_seq2seq
# Get Data
X, Y, I = self.SPDataset.get_3D_data(dataset=dataset,
scaled_X=self.SPModel.request_scaled_X,
scaled_Y=self.SPModel.request_scaled_Y,
timesteps=timesteps,
shift=1,
indices=indices,
seq2seq_prediction=self.SPModel.seq2seq_prediction)
# Predict
print('Predicting ...')
y_pred = self.SPModel.predict([*X,*I])
# Unscale Prediction
if unscale_data and self.SPModel.request_scaled_Y:
Y = self.SPDataset._unscale_Y(Y)
y_pred = self.SPDataset._unscale_Y(y_pred)
# Output Tensors
if output_tensors=='all':
output_tensors=np.arange(0,len(y_pred))
# Plot
print('Plotting ...')
for i_Y in output_tensors:
# Plot
dt = self.SPDataset.dt
if self.SPDataset.dt is None:
dt = 1
if dataset == 'train':
n = self.SPDataset.n_train
elif dataset == 'val':
n = self.SPDataset.n_val
elif dataset == 'test':
n = self.SPDataset.n_test
else:
print('Invalid data set choice.')
Y_curr = Y[i_Y]#np.concatenate([*Y],axis=2)
y_pred_curr = y_pred[i_Y]
Y_signal_names = []
for name in self.SPDataset.Y_signal_names:
Y_signal_names = Y_signal_names + name
print(Y_curr.shape)
print(y_pred_curr.shape)
error_curr = Y_curr - y_pred_curr
plt.figure()
sp = plt.subplot(error_curr.shape[2],1,1)
for i in range(error_curr.shape[2]):
if i>0:
plt.subplot(error_curr.shape[2],1,i+1,sharex=sp)
if timesteps is None:
t = np.arange(0,np.int(np.ceil(n/downsample)))*dt*downsample
plt.plot(t,error_curr[0,::downsample,i],label=Y_signal_names[i])
else:
t = np.arange(0,np.int(np.ceil(error_curr.shape[0]/downsample)))*dt*downsample
plt.plot(t,error_curr[::downsample,-1,i],label=Y_signal_names[i])
plt.ylabel('Output')
if self.SPDataset.Y_signal_names is not(None):
plt.legend()
if self.SPDataset.dt is not(None):
plt.xlabel('Time t [s]')
else:
plt.xlabel('Timestep k')
plt.title('Error Plot - Data Set: ' + dataset)
plt.grid()
def show_training_curves(self,metric=0):
keys = self.training_history.get_history_keys()
if len(keys)==0:
raise ReferenceError('No history available.')
# Get Name of Metric
if type(metric) is str:
metric_name = metric
else:
metric_names = keys
metric_name = metric_names[metric]
# Prepare Plot
plt.figure()
axtrain=plt.subplot(1,1,1)
plt.title('Training Curves')
plt.ylabel('Error')
# Plot
axtrain.semilogy(self.training_history.history[metric_name],label='training')
axtrain.semilogy(self.training_history.history['val_'+metric_name],label='validation')
plt.legend()
plt.grid()
def _f_GPyOpt_construct_function_arguments(self,x):
# Function Arguments
model_arguments = self.SPModel._funargs[0]
if 'self' in model_arguments.keys():
del model_arguments['self']
# Get Hyperparameters
hyperparam_fixed = self.training_history.GPyOpt_fixed_param
hyperparam_bounds = self.training_history.GPyOpt_bounds
# Map Parameters from settings
for hyperpar,val in hyperparam_fixed.items():
if hyperpar in model_arguments['settings'].keys():
model_arguments['settings'][hyperpar] = val
elif hyperpar in model_arguments['settings_opt'].keys():
model_arguments['settings_opt'][hyperpar] = val
x_names = []
for hyperpar,val in zip(hyperparam_bounds,x[0]):
if hyperpar['name'] in model_arguments['settings'].keys():
model_arguments['settings'][hyperpar['name']] = val
x_names.append(hyperpar['name'])
elif hyperpar['name'] in model_arguments['settings_opt'].keys():
model_arguments['settings_opt'][hyperpar['name']] = val
x_names.append(hyperpar['name'])
return model_arguments, x_names
def _f_GPyOpt_model_name(self,model_name,x):
# Get Hyperparameters
hyperparam_bounds = self.training_history.GPyOpt_bounds
# Construct Model Names
savename = model_name if model_name is not(None) else 'Model'
for hyperpar,val in zip(hyperparam_bounds,x[0]):
savename = savename + '_' + hyperpar['name'] + '{:1.5f}'.format(val)
savename = savename.replace('.','p') + '.spm'
return savename
def _f_GPyOpt(self,x):
# Function Arguments
model_arguments, x_names = self._f_GPyOpt_construct_function_arguments(x)
# Create and Initialize Model
modelobj = type(self.SPModel)
spmodel = modelobj(**model_arguments)
# Get Target
target_train = spmodel.get_metric_names()[self._GPyOpt_target]
target_val = 'val_'+spmodel.get_metric_names()[self._GPyOpt_target]
#self._GPyOpt_target_name_list.append(spmodel.get_metric_names()[self._GPyOpt_target])
print('Target is {:s}'.format(target_val))
# Create Callbacks
savename = self._f_GPyOpt_model_name(spmodel.name,x)
path = self.name+'/'+self._GPyOpt_savepath if self.name else self._GPyOpt_savepath
ensure_dir(path)
savename_full = path+'/'+savename
callbacks=[ModelCheckpoint(savename_full, monitor=target_val, save_best_only=True)]#,save_weights_only=True)]
# Fit Model
sptrainer = SPModelTrainer(SPModel=spmodel,SPDataset=self.SPDataset)
if self._fit_generator:
sptrainer.fit_model_generator(**self._GPyOpt_fit_args,callbacks=callbacks)
else:
sptrainer.fit_model(**self._GPyOpt_fit_args,callbacks=callbacks)
# Calculate Loss on Val
minimum_val_loss = np.min(sptrainer.training_history.history[target_val])
# Save Results
self._GPyOpt_min_val_loss.append(minimum_val_loss)
self.training_history._append_GPyOpt(model_arguments,
history=sptrainer.training_history.history,
target_train=target_train,
target_val=target_val,
minimum_val_loss=minimum_val_loss,
savepath=path,
savename=savename,
x_names=x_names,
x=x)
# Return Minimum of Val Loss for Optimization
return minimum_val_loss
def hyperparam_search_init(self,hyperparam_bounds,hyperparam_fixed=None,target=0,GPyOpt_fit_args={},savepath='hyperpar_opt',initial_design_numdata=1,fit_generator=False):
'''
Optimizes the Hyperparameters of the SPModel for minimum validation error.
# Arguments
'''
# Ensure Results Dir
self._GPyOpt_savepath = savepath
ensure_dir(savepath)
# Get Constructer Arguments of SPModel
self.training_history.GPyOpt_bounds = hyperparam_bounds
self.training_history.GPyOpt_fixed_param = hyperparam_fixed
# Fit Method Preparation
self._GPyOpt_target = target
self._GPyOpt_fit_args = GPyOpt_fit_args
self._fit_generator = fit_generator
# Summaries and other Saves
self._GPyOpt_min_val_loss = []
# Create GPyOpt Optimizer
self._GPyOpt_opt = GPyOpt.methods.BayesianOptimization(f=self._f_GPyOpt, domain=hyperparam_bounds, initial_design_numdata=initial_design_numdata)
def hyperparam_search_run(self,max_iter=10):
# Run Optimization
self._GPyOpt_opt.run_optimization(max_iter=max_iter)
def _load_optimal_weights(self):
for model in self.SPModel.models:
model.load_weights(self.training_history.GPyOpt['best_run'][-1]['model'])#,by_name=True)
def get_optimal_spmodel(self):
# Load Optimal Model Weights from Checkpoint
self._load_optimal_weights()
return self.SPModel
def show_hyperparam_training_curves(self,semilogy=True):
'''
Visualization of a performed hyperparam_search().
'''
# Color Setup
colour_start = np.array([27, 79, 114])/256
colour_end = np.array([235, 245, 251])/256
num_colours = len(self.training_history.GPyOpt['runs'])
colors = get_color_setup(colour_start,colour_end,num_colours)
# Plot
plt.figure()
axtrain=plt.subplot(2,1,1)
plt.title('Training Curves')
plt.ylabel('Training Error')
axval=plt.subplot(2,1,2,sharex=axtrain)
plt.ylabel('Validation Error')
plt.xlabel('Epochs [-]')
for run_,color in zip(self.training_history.GPyOpt['runs'],colors):
if semilogy:
axtrain.semilogy(run_['history'][run_['target_train']],color=color)
axval.semilogy(run_['history'][run_['target_val']],color=color)
else:
axtrain.plot(run_['history'][run_['target_train']],color=color)
axval.plt(run_['history'][run_['target_val']],color=color)
axtrain.legend([run_['target_train']])
axval.legend([run_['target_val']])
axtrain.grid()
axval.grid()
def show_2d_optimization(self):
print('Not implemented yet.')
class SPTrainingHistory():
def __init__(self):
self.history = {}
self.GPyOpt = {'hyperparam_bounds':[],'hyperparam_fixed':[],'summaries':[], 'runs':[], 'best_run':[], 'savepath':[]}
print(' ')
def get_history_keys(self):
return list(self.history.keys())
def _append_history(self,new_history):
# Assert Matching History Keys
nhkeys = new_history.keys()
ohkeys = self.get_history_keys()
assert len(nhkeys)==len(ohkeys) or not(ohkeys)
if ohkeys:
for nhk in nhkeys:
assert nhk in ohkeys
# Append history
for key in new_history.keys():
self.history[key] = new_history[key] if self.history is not(None) else self.history[key] + new_history[key]
def _append_GPyOpt(self,model_arguments,history,target_train,target_val,minimum_val_loss,savepath,savename,x_names,x):
# Save Results
self.GPyOpt['runs'].append({'target_train':target_train,
'target_val':target_val,
'minimum_val_loss':minimum_val_loss,
'model':savepath+'/'+savename,
'x_opt':x,
'x_opt_names':x_names,
'history':history,
'model_arguments':model_arguments})
# Document Best Model
first_run = len(self.GPyOpt['best_run'])==0
new_model_better = self.GPyOpt['best_run'][-1]['minimum_val_loss'] > minimum_val_loss if not(first_run) else True
if new_model_better:
self.GPyOpt['best_run'].append(self.GPyOpt['runs'][-1])
@property
def GPyOpt_target(self):
return self.GPyOpt['target']
@GPyOpt_target.setter
def GPyOpt_target(self,target):
self.GPyOpt['target'] = target
@property
def GPyOpt_bounds(self):
return self.GPyOpt['hyperparam_bounds']
@GPyOpt_bounds.setter
def GPyOpt_bounds(self,bounds):
self.GPyOpt['hyperparam_bounds'] = bounds
@property
def GPyOpt_fixed_param(self):
return self.GPyOpt['hyperparam_fixed']
@GPyOpt_fixed_param.setter
def GPyOpt_fixed_param(self,param):
self.GPyOpt['hyperparam_fixed'] = param
|
{"hexsha": "eec7e32853f342902f242cf18daaf26e829c4565", "size": 22932, "ext": "py", "lang": "Python", "max_stars_repo_path": "StatePerception/Trainer.py", "max_stars_repo_name": "graebe/StatePerception", "max_stars_repo_head_hexsha": "bba6743ef95ba5f1d693ba9d409188e37b0d95ec", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "StatePerception/Trainer.py", "max_issues_repo_name": "graebe/StatePerception", "max_issues_repo_head_hexsha": "bba6743ef95ba5f1d693ba9d409188e37b0d95ec", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "StatePerception/Trainer.py", "max_forks_repo_name": "graebe/StatePerception", "max_forks_repo_head_hexsha": "bba6743ef95ba5f1d693ba9d409188e37b0d95ec", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.7914893617, "max_line_length": 175, "alphanum_fraction": 0.5379818594, "include": true, "reason": "import numpy", "num_tokens": 4540}
|
import deepmatcher as dm
import numpy as np
np.random.seed(42)
import random
random.seed(42)
if __name__ == "__main__":
data_dir = "/home/zz/Work/data/deepmatcher_toy/sample_data/itunes-amazon"
train, validation, test = \
dm.data.process(path=data_dir,
check_cached_data=False,
embeddings='fasttext.wiki.vec',
embeddings_cache_path=data_dir+"/embedding_cache",
train='train.csv', validation='validation.csv', test='test.csv')
model = dm.MatchingModel()
model.run_train(train, validation, best_save_path=None)
model.run_eval(test)
# unlabeled = dm.data.process_unlabeled(path='data_directory/unlabeled.csv', trained_model=model)
# model.run_prediction(unlabeled)
'''
This method is important for reading/caching embeddings
The param 'embeddings' is only a name for identifying the embeddings. DM only support a limited set of
these names. And when a recognisable name is supplied, it will attempt to download it. This means if you want to use
a custom embedding, you need to 'hack it' by renaming your model using one of the expected names, and keep the
same format. As an example, when embedding=fasttext.wiki.vec, DM will look for:
https://dl.fbaipublicfiles.com/fasttext/vectors-english/wiki-news-300d-1M.vec.zip
You can pre-download this and save it into: [embeddings_cache_path] (see the code below)
Then upon running this method, it will create a .pt file based on this downloaded embedding, saved in the same
folder above.
At the same time, some cache data are saved in the 'path' parameter (your data folder).
By default, the next time DM runs, it will try to use the cache. So if you change 'embeddings', it will not work
because it will try to look for the cache. You need to delete the cache, or set 'check_cached_data=False' in order
to re-run DM from a fresh start and use a different embedding model
'''
|
{"hexsha": "cacd15bd541f6934f979688a2423f230987cd12b", "size": 2017, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/sandbox/dm_test.py", "max_stars_repo_name": "ziqizhang/wop_matching", "max_stars_repo_head_hexsha": "dd1beb12284c1dd43889c09b4935b8fe20f7c36c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/sandbox/dm_test.py", "max_issues_repo_name": "ziqizhang/wop_matching", "max_issues_repo_head_hexsha": "dd1beb12284c1dd43889c09b4935b8fe20f7c36c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sandbox/dm_test.py", "max_forks_repo_name": "ziqizhang/wop_matching", "max_forks_repo_head_hexsha": "dd1beb12284c1dd43889c09b4935b8fe20f7c36c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.9069767442, "max_line_length": 120, "alphanum_fraction": 0.7069905801, "include": true, "reason": "import numpy", "num_tokens": 467}
|
import pickle
import numpy as np
from scipy.stats import entropy
from create_edgelist import read_network
from collections import Counter
G, mapping = read_network(network_type='directed')
scratch_base = '/scratch/larock.t/shipping/results/interpolated_paths/'
#scratch_base = '../results/interpolated_paths/'
data = dict()
with open(scratch_base + 'iterative_paths.txt', 'r') as fin:
pair = (-1,-1)
first = True
prev_pair = None
pair_counter = 0
total_pairs = 0
degs = []
all_routes = []
for line in fin:
path, mr_dist, route_dist, *routes = line.strip().split('|')
path = path.split(',')
pair = path[0], path[-1]
if pair != prev_pair and not first:
data[prev_pair] = dict()
deg_counts = [d for _,d in sorted(dict(Counter(degs)).items())]
deg_ent = entropy(deg_counts)
data[prev_pair]['deg_ent'] = deg_ent
if deg_ent > 0.0:
data[prev_pair]['deg_ent_normed'] = deg_ent / np.log(len(deg_counts))
else:
data[prev_pair]['deg_ent_normed'] = 0.0
rt_counts = [d for _,d in sorted(dict(Counter(all_routes)).items())]
rt_ent = entropy(rt_counts)
data[prev_pair]['route_ent'] = rt_ent
if rt_ent > 0.0:
data[prev_pair]['route_ent_normed'] = rt_ent / np.log(len(rt_counts))
else:
data[prev_pair]['route_ent_normed'] = 0.0
degs = []
all_routes = []
pair_counter += 1
total_pairs += 1
if pair_counter == 50_000:
print(total_pairs, flush=True)
pair_counter = 0
degs += [G.degree(mapping[node]) for node in path]
all_routes += [r for rt in routes for r in rt]
prev_pair = pair
if first: first = False
with open(scratch_base + 'deg_route_entropy.pickle', 'wb') as fpickle:
pickle.dump(data, fpickle)
|
{"hexsha": "1d750f2c6f3ea3b8578c49c2699ccda8b7f97255", "size": 1978, "ext": "py", "lang": "Python", "max_stars_repo_path": "code/degreeseq_vs_routeseq.py", "max_stars_repo_name": "tlarock/shipping", "max_stars_repo_head_hexsha": "9d8e608e98824281126248d726783eda8ddf80f5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code/degreeseq_vs_routeseq.py", "max_issues_repo_name": "tlarock/shipping", "max_issues_repo_head_hexsha": "9d8e608e98824281126248d726783eda8ddf80f5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/degreeseq_vs_routeseq.py", "max_forks_repo_name": "tlarock/shipping", "max_forks_repo_head_hexsha": "9d8e608e98824281126248d726783eda8ddf80f5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.701754386, "max_line_length": 85, "alphanum_fraction": 0.5829120324, "include": true, "reason": "import numpy,from scipy", "num_tokens": 499}
|
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '0'
from numpy.random import randn, randint
from decimal import Decimal
from tqdm import tqdm
import pickle
from tensorflow.keras.utils import plot_model
from cDCGAN.Discriminator import make_discriminator
from cDCGAN.Generator import make_generator
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from tensorflow import keras
IM_SIZE = 32*13
OUTPUT_DIR = "./img"
IMAGE_DIR = 'IMAGE DIR'
# evaluate the discriminator, plot generated images, save generator model
def summarize_performance(epoch, g_model, d_model, dataset, latent_dim, n_samples=150):
# prepare real samples
X_real, y_real = generate_real_samples(dataset, n_samples)
# evaluate discriminator on real examples
_, acc_real = d_model.evaluate(X_real, y_real, verbose=0)
# prepare fake examples
x_fake, y_fake = generate_fake_samples(g_model, latent_dim, n_samples)
# evaluate discriminator on fake examples
_, acc_fake = d_model.evaluate(x_fake, y_fake, verbose=0)
# summarize discriminator performance
print('>Accuracy real: %.0f%%, fake: %.0f%%' % (acc_real*100, acc_fake*100))
# save plot
save_plot(x_fake, epoch)
# save the generator model
filename = f'./models/generator_model_{epoch+1}.h5'
g_model.save(filename)
# create and save a plot of generated images
def save_plot(examples, epoch, n=1):
# scale from [-1,1] to [0,1]
examples = (examples + 1) / 2.0
# plot images
for i in range(n * n):
# define subplot
plt.subplot(n, n, 1 + i)
# turn off axis
plt.axis('off')
# plot raw pixel data
plt.imshow(examples[i])
# save plot to file
filename = f'./plots/generated_plot_epoch_{epoch+1}.png'
plt.savefig(filename)
plt.close()
# example of smoothing class=1 to [0.8, 1.2]
def smooth_positive_labels(y):
return y - 0.3 + (np.random.random(y.shape) * 0.3)
def smooth_negative_labels(y):
return y + np.random.random(y.shape) * 0.3
# generate points in latent space as input for the generator
def generate_latent_points(latent_dim, n_samples):
# generate points in the latent space
x_input = randn(latent_dim * n_samples)
# reshape into a batch of inputs for the network
x_input = x_input.reshape(n_samples, latent_dim)
return x_input
# load and prepare cifar10 training images
def load_real_samples():
with open('train_images.pkl', 'rb') as f:
train_images = pickle.load(f)
train_images = train_images.reshape(train_images.shape[0], IM_SIZE, IM_SIZE, 3).astype('float32')
# train_dataset = tf.data.Dataset.from_tensor_slices(train_images).shuffle(BUFFER_SIZE).batch(BATCH_SIZE)
return train_images
# select real samples
def generate_real_samples(dataset, n_samples):
# choose random instances
ix = randint(0, dataset.shape[0], n_samples)
# retrieve selected images
X = dataset[ix]
# generate 'real' class labels (1)
y = np.ones((n_samples, 1))
y = smooth_positive_labels(y)
return X, y
def generate_fake_samples(generator, latent_dim, n_samples):
# generate points in latent space
x_input = generate_latent_points(latent_dim, n_samples)
# predict outputs
X = generator.predict(x_input)
# create 'fake' class labels (0)
y = np.zeros((n_samples, 1))
y = smooth_negative_labels(y)
return X, y
# define the combined generator and discriminator model, for updating the generator
def define_gan(g_model, d_model):
# make weights in the discriminator not trainable
d_model.trainable = False
# connect them
model = keras.Sequential()
# add generator
model.add(g_model)
# add the discriminator
model.add(d_model)
# compile model
opt = keras.optimizers.Adam(lr=0.0002, beta_1=0.5)
model.compile(loss='binary_crossentropy', optimizer=opt)
return model
# train the generator and discriminator
def train(g_model, d_model, gan_model, dataset, latent_dim, n_epochs=200, n_batch=56):
bat_per_epo = int(dataset.shape[0] / n_batch)
half_batch = int(n_batch / 2)
# manually enumerate epochs
for i in tqdm(range(n_epochs), leave=True):
# enumerate batches over the training set
for j in range(bat_per_epo):
# get randomly selected 'real' samples
X_real, y_real = generate_real_samples(dataset, half_batch)
# update discriminator model weights
d_loss1, _ = d_model.train_on_batch(X_real, y_real)
# generate 'fake' examples
X_fake, y_fake = generate_fake_samples(g_model, latent_dim, half_batch)
# update discriminator model weights
d_loss2, _ = d_model.train_on_batch(X_fake, y_fake)
# prepare points in latent space as input for the generator
X_gan = generate_latent_points(latent_dim, n_batch)
# create inverted labels for the fake samples
y_gan = np.ones((n_batch, 1))
# update the generator via the discriminator's error
g_loss = gan_model.train_on_batch(X_gan, y_gan)
# summarize loss on this batch
print(f'Epoch: {i+1}, '
f'batch pr. epoch: {j+1}/{bat_per_epo} '
f'd1= {round(Decimal(str(d_loss1)), 5)}, '
f'd2= {round(Decimal(str(d_loss2)), 5)} '
f'g= {round(Decimal(str(g_loss)), 5)}')
if (i + 1) % 40 == 0:
summarize_performance(i, g_model, d_model, dataset, latent_dim)
if __name__ == "__main__":
physical_devices = tf.config.experimental.list_physical_devices('GPU')
if len(physical_devices) > 0:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
# Size of latent space
latent_dim = 100
# Create the generator model
generator = make_generator(latent_dim=latent_dim)
# Create the discriminator model
diskriminator = make_discriminator()
generator.summary()
diskriminator.summary()
plot_model(generator, to_file='generator-model-plot.png', show_shapes=True, show_layer_names=True)
plot_model(diskriminator, to_file='diskriminator-model-plot.png', show_shapes=True, show_layer_names=True)
# Create the GAN
gan_model = define_gan(g_model=generator, d_model=diskriminator)
# plot_model(diskriminator, to_file='diskriminator-model-plot.png', show_shapes=True, show_layer_names=True)
# Load images of pipes with ice
samples = load_real_samples()
# train model
train(generator, diskriminator, gan_model, samples, latent_dim, n_epochs=40000, n_batch=4)
|
{"hexsha": "f3eead6a15850b160fdbbecd28d6381ab9d0348e", "size": 6840, "ext": "py", "lang": "Python", "max_stars_repo_path": "cDCGAN/cdcgan.py", "max_stars_repo_name": "Laende/Bacheloroppgave-droneteknologi", "max_stars_repo_head_hexsha": "15d9b2cd0eeba47fd2e9615fb01d598516826194", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cDCGAN/cdcgan.py", "max_issues_repo_name": "Laende/Bacheloroppgave-droneteknologi", "max_issues_repo_head_hexsha": "15d9b2cd0eeba47fd2e9615fb01d598516826194", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cDCGAN/cdcgan.py", "max_forks_repo_name": "Laende/Bacheloroppgave-droneteknologi", "max_forks_repo_head_hexsha": "15d9b2cd0eeba47fd2e9615fb01d598516826194", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0298507463, "max_line_length": 113, "alphanum_fraction": 0.6700292398, "include": true, "reason": "import numpy,from numpy", "num_tokens": 1646}
|
[STATEMENT]
lemma nn_integral_count_space_reindex:
"inj_on f A \<Longrightarrow>(\<integral>\<^sup>+ y. g y \<partial>count_space (f ` A)) = (\<integral>\<^sup>+ x. g (f x) \<partial>count_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. inj_on f A \<Longrightarrow> integral\<^sup>N (count_space (f ` A)) g = \<integral>\<^sup>+ x. g (f x) \<partial>count_space A
[PROOF STEP]
by(simp add: embed_measure_count_space'[symmetric] nn_integral_embed_measure' measurable_embed_measure1)
|
{"llama_tokens": 190, "file": "MFMC_Countable_MFMC_Misc", "length": 1}
|
"""
SubgradientMaster
Implementation of projected subgradient method
"""
mutable struct SubgradientMaster <: AbstractLagrangeMaster
num_vars::Int
num_functions::Int
eval_f::Union{Nothing,Function}
iter::Int # current iteration count
maxiter::Int
obj_limit::Float64
f::Float64
best_f::Float64
x::Vector{Float64}
best_x::Vector{Float64}
∇f::Vector{Float64}
α::Float64 # step size
step_size::Function
constraint_matrix::Union{Nothing,SparseMatrixCSC{Float64,Int}}
iteration_time::Vector{Float64}
function SubgradientMaster()
sg = new()
sg.num_vars = 0
sg.num_functions = 0
sg.eval_f = nothing
sg.iter = 0
sg.maxiter = 1000
sg.obj_limit = +Inf
sg.f = -Inf
sg.best_f = -Inf
sg.x = []
sg.best_x = []
sg.∇f = []
sg.α = 0.1
# sg.step_size = (method) -> method.α / method.iter # square summable but not summable
sg.step_size = (method) -> method.α / sqrt(method.iter) # Nonsummable diminishing
sg.constraint_matrix = nothing
sg.iteration_time = []
return sg
end
end
function load!(method::SubgradientMaster, num_coupling_variables::Int, num_blocks::Int, eval_function::Function, init_sol::Vector{Float64})
method.num_vars = num_coupling_variables
method.num_functions = num_blocks
method.eval_f = eval_function
method.x = init_sol
method.best_x = init_sol
end
function add_constraints!(LD::AbstractLagrangeDual, method::SubgradientMaster)
I = Int[]; J = Int[]; V = Float64[]
row = 1
for (id, vars) in LD.block_model.variables_by_couple
for v in vars
push!(I, row)
push!(J, index_of_λ(LD, v))
push!(V, 1.0)
end
row += 1
end
method.constraint_matrix = sparse(I, J, V)
end
function run!(method::SubgradientMaster)
# projection matrix
m, n = size(method.constraint_matrix)
I = sparse(SparseArrays.I, n, n)
A = method.constraint_matrix
proj = transpose(A) * ((A * transpose(A)) \ A)
total_time = 0.0
total_master_time = 0.0
total_stime = time()
method.∇f = zeros(method.num_vars)
while method.iter < method.maxiter
method.iter += 1
if method.iter % 100 == 1
@printf("%6s", "Iter")
@printf("\t%13s", "fbest")
@printf("\t%13s", "f")
@printf("\t%13s", "|∇f|")
@printf("\t%13s", "α")
# @printf("\t%13s", "res")
@printf("\t%7s", "sg time")
@printf("\t%8s", "tot time")
@printf("\n")
end
f, g = method.eval_f(method.x)
method.f = -sum(f)
if method.best_f < method.f
method.best_f = method.f
copy!(method.best_x, method.x)
end
master_stime = time()
fill!(method.∇f, 0.0)
for (k, gk) in g
method.∇f .+= gk
end
# update
α = method.step_size(method)
method.x .-= α * method.∇f
# projection
method.x .-= proj * method.x
# res = method.constraint_matrix * method.x
# clock iteration time
push!(method.iteration_time, time() - master_stime)
total_master_time += time() - master_stime
total_time = time() - total_stime
@printf("%6d", method.iter)
@printf("\t%+6e", method.best_f)
@printf("\t%+6e", method.f)
@printf("\t%+6e", norm(method.∇f))
@printf("\t%+6e", α)
# @printf("\t%+6e", norm(res))
@printf("\t%7.2f", total_master_time)
@printf("\t%8.2f", total_time)
@printf("\n")
if method.obj_limit < method.best_f
break
end
end
end
get_objective(method::SubgradientMaster) = method.best_f
get_solution(method::SubgradientMaster) = method.best_x
get_times(method::SubgradientMaster)::Vector{Float64} = method.iteration_time
function set_obj_limit!(method::SubgradientMaster, val::Float64)
method.obj_limit = val
end
|
{"hexsha": "e95599ce178e18658f47883c746b08abd02e4c51", "size": 4085, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/LagrangeMaster/SubgradientMethod.jl", "max_stars_repo_name": "kibaekkim/JuDD.jl", "max_stars_repo_head_hexsha": "de25e24f1475e3aaa5908335ba6749e88125c953", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 12, "max_stars_repo_stars_event_min_datetime": "2020-07-14T22:27:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T21:00:09.000Z", "max_issues_repo_path": "src/LagrangeMaster/SubgradientMethod.jl", "max_issues_repo_name": "CanLi1/DualDecomposition.jl", "max_issues_repo_head_hexsha": "de25e24f1475e3aaa5908335ba6749e88125c953", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 36, "max_issues_repo_issues_event_min_datetime": "2020-07-14T22:24:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T15:40:11.000Z", "max_forks_repo_path": "src/LagrangeMaster/SubgradientMethod.jl", "max_forks_repo_name": "kibaekkim/JuDD.jl", "max_forks_repo_head_hexsha": "de25e24f1475e3aaa5908335ba6749e88125c953", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-01-19T21:13:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T21:00:11.000Z", "avg_line_length": 27.6013513514, "max_line_length": 139, "alphanum_fraction": 0.5813953488, "num_tokens": 1152}
|
from collections.abc import Sequence
import numbers
import numpy as np
from brian2.core.variables import Variables, get_dtype
from brian2.groups.group import Group, CodeRunner
from brian2.utils.logger import get_logger
from brian2.units.fundamentalunits import Quantity
from brian2.units.allunits import second
__all__ = ['StateMonitor']
logger = get_logger(__name__)
class StateMonitorView(object):
def __init__(self, monitor, item):
self.monitor = monitor
self.item = item
self.indices = self._calc_indices(item)
self._group_attribute_access_active = True
def __getattr__(self, item):
# We do this because __setattr__ and __getattr__ are not active until
# _group_attribute_access_active attribute is set, and if it is set,
# then __getattr__ will not be called. Therefore, if getattr is called
# with this name, it is because it hasn't been set yet and so this
# method should raise an AttributeError to agree that it hasn't been
# called yet.
if item == '_group_attribute_access_active':
raise AttributeError
if not hasattr(self, '_group_attribute_access_active'):
raise AttributeError
mon = self.monitor
if item == 't':
return Quantity(mon.variables['t'].get_value(), dim=second.dim)
elif item == 't_':
return mon.variables['t'].get_value()
elif item in mon.record_variables:
dims = mon.variables[item].dim
return Quantity(mon.variables[item].get_value().T[self.indices],
dim=dims, copy=True)
elif item.endswith('_') and item[:-1] in mon.record_variables:
return mon.variables[item[:-1]].get_value().T[self.indices].copy()
else:
raise AttributeError(f'Unknown attribute {item}')
def _calc_indices(self, item):
"""
Convert the neuron indices to indices into the stored values. For example, if neurons [0, 5, 10] have been
recorded, [5, 10] is converted to [1, 2].
"""
dtype = get_dtype(item)
# scalar value
if np.issubdtype(dtype, np.signedinteger) and not isinstance(item, np.ndarray):
indices = np.nonzero(self.monitor.record == item)[0]
if len(indices) == 0:
raise IndexError(f'Index number {int(item)} has not been recorded')
return indices[0]
if self.monitor.record_all:
return item
indices = []
for index in item:
if index in self.monitor.record:
indices.append(np.nonzero(self.monitor.record == index)[0][0])
else:
raise IndexError(f'Index number {int(index)} has not been recorded')
return np.array(indices)
def __repr__(self):
classname = self.__class__.__name__
return (f"<{classname}, giving access to elements {self.item!r} recorded by "
f"{self.monitor.name}>")
class StateMonitor(Group, CodeRunner):
"""
Record values of state variables during a run
To extract recorded values after a run, use the ``t`` attribute for the
array of times at which values were recorded, and variable name attribute
for the values. The values will have shape ``(len(indices), len(t))``,
where ``indices`` are the array indices which were recorded. When indexing
the `StateMonitor` directly, the returned object can be used to get the
recorded values for the specified indices, i.e. the indexing semantic
refers to the indices in ``source``, not to the relative indices of the
recorded values. For example, when recording only neurons with even numbers,
`mon[[0, 2]].v` will return the values for neurons 0 and 2, whereas
`mon.v[[0, 2]]` will return the values for the first and third *recorded*
neurons, i.e. for neurons 0 and 4.
Parameters
----------
source : `Group`
Which object to record values from.
variables : str, sequence of str, True
Which variables to record, or ``True`` to record all variables
(note that this may use a great deal of memory).
record : bool, sequence of ints
Which indices to record, nothing is recorded for ``False``,
everything is recorded for ``True`` (warning: may use a great deal of
memory), or a specified subset of indices.
dt : `Quantity`, optional
The time step to be used for the monitor. Cannot be combined with
the `clock` argument.
clock : `Clock`, optional
The update clock to be used. If neither a clock, nor the ``dt`` argument
is specified, the clock of the `source` will be used.
when : str, optional
At which point during a time step the values should be recorded.
Defaults to ``'start'``.
order : int, optional
The priority of of this group for operations occurring at the same time
step and in the same scheduling slot. Defaults to 0.
name : str, optional
A unique name for the object, otherwise will use
``source.name+'statemonitor_0'``, etc.
codeobj_class : `CodeObject`, optional
The `CodeObject` class to create.
Examples
--------
Record all variables, first 5 indices::
eqs = '''
dV/dt = (2-V)/(10*ms) : 1
'''
threshold = 'V>1'
reset = 'V = 0'
G = NeuronGroup(100, eqs, threshold=threshold, reset=reset)
G.V = rand(len(G))
M = StateMonitor(G, True, record=range(5))
run(100*ms)
plot(M.t, M.V.T)
show()
Notes
-----
Since this monitor by default records in the ``'start'`` time slot,
recordings of the membrane potential in integrate-and-fire models may look
unexpected: the recorded membrane potential trace will never be above
threshold in an integrate-and-fire model, because the reset statement will
have been applied already. Set the ``when`` keyword to a different value if
this is not what you want.
Note that ``record=True`` only works in runtime mode for synaptic variables.
This is because the actual array of indices has to be calculated and this is
not possible in standalone mode, where the synapses have not been created
yet at this stage. Consider using an explicit array of indices instead,
i.e. something like ``record=np.arange(n_synapses)``.
"""
invalidates_magic_network = False
add_to_magic_network = True
def __init__(self, source, variables, record, dt=None, clock=None,
when='start', order=0, name='statemonitor*', codeobj_class=None):
self.source = source
# Make the monitor use the explicitly defined namespace of its source
# group (if it exists)
self.namespace = getattr(source, 'namespace', None)
self.codeobj_class = codeobj_class
# run by default on source clock at the end
if dt is None and clock is None:
clock = source.clock
# variables should always be a list of strings
if variables is True:
variables = source.equations.names
elif isinstance(variables, str):
variables = [variables]
#: The variables to record
self.record_variables = variables
# record should always be an array of ints
self.record_all = False
if hasattr(record, '_indices'):
# The ._indices method always returns absolute indices
# If the source is already a subgroup of another group, we therefore
# have to shift the indices to become relative to the subgroup
record = record._indices() - getattr(source, '_offset', 0)
if record is True:
self.record_all = True
try:
record = np.arange(len(source), dtype=np.int32)
except NotImplementedError:
# In standalone mode, this is not possible for synaptic
# variables because the number of synapses is not defined yet
raise NotImplementedError("Cannot determine the actual "
"indices to record for record=True. "
"This can occur for example in "
"standalone mode when trying to "
"record a synaptic variable. "
"Consider providing an explicit "
"array of indices for the record "
"argument.")
elif record is False:
record = np.array([], dtype=np.int32)
elif isinstance(record, numbers.Number):
record = np.array([record], dtype=np.int32)
else:
record = np.asarray(record, dtype=np.int32)
#: The array of recorded indices
self.record = record
self.n_indices = len(record)
# Some dummy code so that code generation takes care of the indexing
# and subexpressions
code = [f'_to_record_{v} = _source_{v}'
for v in variables]
code = '\n'.join(code)
CodeRunner.__init__(self, group=self, template='statemonitor',
code=code, name=name,
clock=clock,
dt=dt,
when=when,
order=order,
check_units=False)
self.add_dependency(source)
# Setup variables
self.variables = Variables(self)
self.variables.add_dynamic_array('t', size=0, dimensions=second.dim,
constant=False,
dtype=self._clock.variables['t'].dtype)
self.variables.add_array('N', dtype=np.int32, size=1, scalar=True,
read_only=True)
self.variables.add_array('_indices', size=len(self.record),
dtype=self.record.dtype, constant=True,
read_only=True, values=self.record)
self.variables.create_clock_variables(self._clock,
prefix='_clock_')
for varname in variables:
var = source.variables[varname]
if var.scalar and len(self.record) > 1:
logger.warn(('Variable %s is a shared variable but it will be '
'recorded once for every target.' % varname),
once=True)
index = source.variables.indices[varname]
self.variables.add_reference(f'_source_{varname}',
source, varname, index=index)
if not index in ('_idx', '0') and index not in variables:
self.variables.add_reference(index, source)
self.variables.add_dynamic_array(varname,
size=(0, len(self.record)),
resize_along_first=True,
dimensions=var.dim,
dtype=var.dtype,
constant=False,
read_only=True)
for varname in variables:
var = self.source.variables[varname]
self.variables.add_auxiliary_variable(f"_to_record_{varname}",
dimensions=var.dim,
dtype=var.dtype,
scalar=var.scalar)
self.recorded_variables = dict([(varname, self.variables[varname])
for varname in variables])
recorded_names = [varname for varname in variables]
self.needed_variables = recorded_names
self.template_kwds = {'_recorded_variables': self.recorded_variables}
self.written_readonly_vars = {self.variables[varname]
for varname in self.record_variables}
self._enable_group_attributes()
def resize(self, new_size):
self.variables['N'].set_value(new_size)
self.variables['t'].resize(new_size)
for var in self.recorded_variables.values():
var.resize((new_size, self.n_indices))
def reinit(self):
raise NotImplementedError()
def __getitem__(self, item):
dtype = get_dtype(item)
if np.issubdtype(dtype, np.signedinteger):
return StateMonitorView(self, item)
elif isinstance(item, Sequence):
index_array = np.array(item)
if not np.issubdtype(index_array.dtype, np.signedinteger):
raise TypeError("Index has to be an integer or a sequence "
"of integers")
return StateMonitorView(self, item)
elif hasattr(item, '_indices'):
# objects that support the indexing interface will return absolute
# indices but here we need relative ones
# TODO: How to we prevent the use of completely unrelated objects here?
source_offset = getattr(self.source, '_offset', 0)
return StateMonitorView(self, item._indices() - source_offset)
else:
raise TypeError(f'Cannot use object of type {type(item)} as an index')
def __getattr__(self, item):
# We do this because __setattr__ and __getattr__ are not active until
# _group_attribute_access_active attribute is set, and if it is set,
# then __getattr__ will not be called. Therefore, if getattr is called
# with this name, it is because it hasn't been set yet and so this
# method should raise an AttributeError to agree that it hasn't been
# called yet.
if item == '_group_attribute_access_active':
raise AttributeError
if not hasattr(self, '_group_attribute_access_active'):
raise AttributeError
if item in self.record_variables:
var_dim = self.variables[item].dim
return Quantity(self.variables[item].get_value().T,
dim=var_dim, copy=True)
elif item.endswith('_') and item[:-1] in self.record_variables:
return self.variables[item[:-1]].get_value().T
else:
return Group.__getattr__(self, item)
def __repr__(self):
classname = self.__class__.__name__
variables = repr(self.record_variables)
description = f"<{classname}, recording {variables} from '{self.source.name}'>"
def record_single_timestep(self):
"""
Records a single time step. Useful for recording the values at the end
of the simulation -- otherwise a `StateMonitor` will not record the
last simulated values since its ``when`` attribute defaults to
``'start'``, i.e. the last recording is at the *beginning* of the last
time step.
Notes
-----
This function will only work if the `StateMonitor` has been already run,
but a run with a length of ``0*ms`` does suffice.
Examples
--------
>>> from brian2 import *
>>> G = NeuronGroup(1, 'dv/dt = -v/(5*ms) : 1')
>>> G.v = 1
>>> mon = StateMonitor(G, 'v', record=True)
>>> run(0.5*ms)
>>> print(np.array_str(mon.v[:], precision=3))
[[ 1. 0.98 0.961 0.942 0.923]]
>>> print(mon.t[:])
[ 0. 100. 200. 300. 400.] us
>>> print(np.array_str(G.v[:], precision=3)) # last value had not been recorded
[ 0.905]
>>> mon.record_single_timestep()
>>> print(mon.t[:])
[ 0. 100. 200. 300. 400. 500.] us
>>> print(np.array_str(mon.v[:], precision=3))
[[ 1. 0.98 0.961 0.942 0.923 0.905]]
"""
if self.codeobj is None:
raise TypeError("Can only record a single time step after the "
"network has been run once.")
self.codeobj()
|
{"hexsha": "d49af0a604ad2883c342c42bf534df3ffde428c6", "size": 16296, "ext": "py", "lang": "Python", "max_stars_repo_path": "brian2/monitors/statemonitor.py", "max_stars_repo_name": "adriangb/brian2", "max_stars_repo_head_hexsha": "eef588f9b258af82dc5f8f06599ecf11bcaae53e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 674, "max_stars_repo_stars_event_min_datetime": "2015-01-14T11:05:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T04:53:50.000Z", "max_issues_repo_path": "brian2/monitors/statemonitor.py", "max_issues_repo_name": "adriangb/brian2", "max_issues_repo_head_hexsha": "eef588f9b258af82dc5f8f06599ecf11bcaae53e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 937, "max_issues_repo_issues_event_min_datetime": "2015-01-05T13:24:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T13:10:13.000Z", "max_forks_repo_path": "brian2/monitors/statemonitor.py", "max_forks_repo_name": "adriangb/brian2", "max_forks_repo_head_hexsha": "eef588f9b258af82dc5f8f06599ecf11bcaae53e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 237, "max_forks_repo_forks_event_min_datetime": "2015-01-05T13:54:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T22:16:32.000Z", "avg_line_length": 44.4032697548, "max_line_length": 114, "alphanum_fraction": 0.5829651448, "include": true, "reason": "import numpy", "num_tokens": 3397}
|
#!/usr/bin/env python3
import numpy as np
from numpy import sin, cos
from numpy.linalg import eig
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt
def system(t, x):
plant = np.array([ [ 0.0, 1.0],
[-1, -0.1] ])
desired_point = np.array([1.0,0.0])
error = desired_point - x
controller_gains = np.array([1,1])
u = np.matmul(controller_gains, error)
controller_actuation = np.array([0.0,1.0])
return np.matmul(plant,x) + controller_actuation * u
if __name__ == "__main__":
xi = np.array([ 1.0, 2.0])
sol = solve_ivp(system, [0,50], xi, max_step=0.1)
plt.plot(sol.t, sol.y[0])
plt.show()
|
{"hexsha": "a74279f16b58d376348508ec74252ef64ea75e71", "size": 675, "ext": "py", "lang": "Python", "max_stars_repo_path": "autopilot/proof.py", "max_stars_repo_name": "FunRoss7/sailing", "max_stars_repo_head_hexsha": "f4c931ea65b5c12ae3d6c4f533cd864da97f908c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "autopilot/proof.py", "max_issues_repo_name": "FunRoss7/sailing", "max_issues_repo_head_hexsha": "f4c931ea65b5c12ae3d6c4f533cd864da97f908c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "autopilot/proof.py", "max_forks_repo_name": "FunRoss7/sailing", "max_forks_repo_head_hexsha": "f4c931ea65b5c12ae3d6c4f533cd864da97f908c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.6818181818, "max_line_length": 56, "alphanum_fraction": 0.6266666667, "include": true, "reason": "import numpy,from numpy,from scipy", "num_tokens": 212}
|
'''Test utilities in xroms'''
import xroms
import xarray as xr
import numpy as np
import cartopy
grid = xr.open_dataset('tests/input/grid.nc')
ds = xr.open_dataset('tests/input/ocean_his_0001.nc')
# combine the two:
ds = ds.merge(grid, overwrite_vars=True, compat='override')
def test_argsel2d():
'''Check that function returns correct indices.
This compares with previous calculation.'''
lon0, lat0 = -95.8, 27.1
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='rho') == (0,1)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='psi') == (0,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='u') == (0,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='v') == (0,1)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='vert') == (1,1)
def test_argsel2d_exact():
'''test for exact index.'''
lon0, lat0 = -95.928571, 27.166685 # one corner of grid
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='rho') == (1,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='psi') == (0,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='u') == (1,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='v') == (0,0)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='vert') == (1,1)
lon0, lat0 = -94.071429, 28.333351 # other corner of grid
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='rho') == (8,13)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='psi') == (7,12)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='u') == (8,12)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='v') == (7,13)
assert xroms.argsel2d(grid, lon0, lat0, whichgrid='vert') == (8,13)
def test_sel2d():
'''Check that function returns correct value for scalar inputs.'''
lon0, lat0 = -94.8, 28.0
assert xroms.utilities.sel2d(ds, lon0, lat0, whichgrid='u').u.isel(s_rho=0, ocean_time=0) == 0.7
assert xroms.utilities.sel2d(ds, lon0, lat0, whichgrid='v').v.isel(s_rho=0, ocean_time=0) == 0.0
def test_sel2d_list():
'''Test sel2d for lon0/lat0 as list.'''
lon0, lat0 = [-95.7,-94.8], [27.4,28.0]
assert (xroms.sel2d(ds, lon0, lat0, whichgrid='u').u.isel(s_rho=0, ocean_time=0) == [0.1, 0.7]).all()
assert (xroms.sel2d(ds, lon0, lat0, whichgrid='v').v.isel(s_rho=0, ocean_time=0) == [0.0, 0.0]).all()
def test_xisoslice():
'''Test xisoslice function.'''
# test longitude slice of u
res = xroms.xisoslice(ds.lon_u, -95, ds.u, 'xi_u')
assert np.allclose(res, 0.6)
# test latitude slice of u
res = xroms.xisoslice(ds.lat_u, 28, ds.u, 'eta_u').std()
assert np.allclose(res, 0.37416574)
# test when slice isn't along a value that is equal along that slice
# convert to projected space
proj = cartopy.crs.LambertConformal(central_longitude=-98, central_latitude=30)
pc = cartopy.crs.PlateCarree()
x_u, y_u = proj.transform_points(pc, ds.lon_u.values, ds.lat_u.values)[...,:2].T
ds['x_u'] = (('eta_u','xi_u'), x_u.T)
res = xroms.xisoslice(ds.x_u, 380000, ds.lon_u, 'xi_u').mean()
assert np.allclose(res, -94.19483976)
# test getting latitude for longitude slice
res = xroms.xisoslice(ds.lon_rho, -94.5, ds.lat_rho, 'xi_rho').mean().values
assert np.allclose(res, 27.75001934)
# test requesting an exact iso_value that is in the iso_array, in xi_rho
lon0 = ds.lon_rho[4,7]
res = xroms.xisoslice(ds.lon_rho, lon0, ds.lat_rho, 'xi_rho')
assert np.allclose(res, ds.lat_rho[:,7])
# test requesting an exact iso_value that is in the iso_array, in eta_rho
lat0 = ds.lat_rho[3,4]
res = xroms.xisoslice(ds.lat_rho, lat0, ds.lon_rho, 'eta_rho')
assert np.allclose(res, ds.lon_rho[3,:])
|
{"hexsha": "84a28285e3e5efeb5ca960ea11194b94d9db6c39", "size": 3745, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_utils.py", "max_stars_repo_name": "ocefpaf/xroms", "max_stars_repo_head_hexsha": "763d6e678e28fe074e0aaab26fecd2b74e51a8b0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-01-21T21:24:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-02T03:09:32.000Z", "max_issues_repo_path": "tests/test_utils.py", "max_issues_repo_name": "ocefpaf/xroms", "max_issues_repo_head_hexsha": "763d6e678e28fe074e0aaab26fecd2b74e51a8b0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-08T00:11:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-25T08:03:45.000Z", "max_forks_repo_path": "tests/test_utils.py", "max_forks_repo_name": "ocefpaf/xroms", "max_forks_repo_head_hexsha": "763d6e678e28fe074e0aaab26fecd2b74e51a8b0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-06T06:42:36.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-06T06:42:36.000Z", "avg_line_length": 38.6082474227, "max_line_length": 105, "alphanum_fraction": 0.6507343124, "include": true, "reason": "import numpy", "num_tokens": 1312}
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import time
import random
import networkx as nx
def random_walk(G, path_length, alpha=0, rand=random.Random(), start=None):
""" Returns a truncated random walk.
path_length: Length of the random walk.
alpha: probability of restarts.
start: the start node of the random walk.
"""
if start:
path = [start]
else:
# Sampling is uniform w.r.t V, and not w.r.t E
path = [rand.choice(list(G.nodes()))]
while len(path) < path_length:
current = path[-1]
neighbors = list(G.neighbors(current))
if len(neighbors) > 0:
if rand.random() >= alpha:
path.append(rand.choice(neighbors))
else:
path.append(path[0])
else:
break
return [node for node in path]
def build_deepwalk_corpus(G, num_paths, path_length, alpha=0,
rand=random.Random(0)):
walks = []
nodes = list(G.nodes())
for cnt in range(num_paths):
rand.shuffle(nodes)
for node in nodes:
walks.append(random_walk(G, path_length, rand=rand, alpha=alpha, start=node))
return walks
|
{"hexsha": "717f95e3d665d5f13a206e5e7ee7834966e49bc1", "size": 1189, "ext": "py", "lang": "Python", "max_stars_repo_path": "algorithms/deepwalk/graph.py", "max_stars_repo_name": "mpoiitis/GraphM-framework", "max_stars_repo_head_hexsha": "82904b9940b029579b86c359e17312cfa7ef1692", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "algorithms/deepwalk/graph.py", "max_issues_repo_name": "mpoiitis/GraphM-framework", "max_issues_repo_head_hexsha": "82904b9940b029579b86c359e17312cfa7ef1692", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "algorithms/deepwalk/graph.py", "max_forks_repo_name": "mpoiitis/GraphM-framework", "max_forks_repo_head_hexsha": "82904b9940b029579b86c359e17312cfa7ef1692", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.847826087, "max_line_length": 89, "alphanum_fraction": 0.5979814971, "include": true, "reason": "import networkx", "num_tokens": 280}
|
/*
* Copyright (c) 2019 Opticks Team. All Rights Reserved.
*
* This file is part of Opticks
* (see https://bitbucket.org/simoncblyth/opticks).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cstddef>
#include <iomanip>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include "BStr.hh"
#include "NGLM.hpp"
#include "GLMFormat.hpp"
#include "NGeoTestConfig.hpp"
#include "PLOG.hh"
// "pmtpath=$IDPATH_DPIB_PMT/GMergedMesh/0_"
// TODO: OpticksResource::getBasePath("dpib/GMergedMesh/0")
// is now used by GPmtLib ... so no need for pmtpath below ?
//
const char* NGeoTestConfig::DEFAULT_CONFIG =
"mode=PmtInBox_"
"pmtpath=$OPTICKSINSTALLPREFIX/opticksdata/export/dpib/GMergedMesh/0_"
"control=1,0,0,0_"
"analytic=1_"
"outerfirst=1_"
"node=box_"
"boundary=Rock/NONE/perfectAbsorbSurface/MineralOil_"
"parameters=0,0,0,300_"
;
const char* NGeoTestConfig::MODE_ = "mode";
const char* NGeoTestConfig::FRAME_ = "frame";
const char* NGeoTestConfig::BOUNDARY_ = "boundary";
const char* NGeoTestConfig::PARAMETERS_ = "parameters";
const char* NGeoTestConfig::NODE_ = "node";
const char* NGeoTestConfig::ANALYTIC_ = "analytic";
const char* NGeoTestConfig::DEBUG_ = "debug";
const char* NGeoTestConfig::CONTROL_ = "control";
const char* NGeoTestConfig::PMTPATH_ = "pmtpath";
const char* NGeoTestConfig::TRANSFORM_ = "transform";
const char* NGeoTestConfig::CSGPATH_ = "csgpath";
const char* NGeoTestConfig::OFFSETS_ = "offsets";
const char* NGeoTestConfig::NAME_ = "name";
const char* NGeoTestConfig::OUTERFIRST_ = "outerfirst";
const char* NGeoTestConfig::AUTOCONTAINER_ = "autocontainer";
const char* NGeoTestConfig::AUTOOBJECT_ = "autoobject";
const char* NGeoTestConfig::AUTOEMITCONFIG_ = "autoemitconfig";
const char* NGeoTestConfig::AUTOSEQMAP_ = "autoseqmap";
NGeoTestConfig::NGeoTestConfig(const char* config)
:
m_config(NULL),
m_mode(NULL),
m_pmtpath(NULL),
m_csgpath(NULL),
m_name(NULL),
m_autocontainer(NULL),
m_autoobject(NULL),
m_autoemitconfig(NULL),
m_autoseqmap(NULL),
m_frame(0,0,0,0),
m_analytic(0,0,0,0),
m_outerfirst(1,0,0,0),
m_debug(1.f,0.f,0.f,0.f),
m_control(0,0,0,0)
{
init(config);
}
std::vector<std::pair<std::string, std::string> >& NGeoTestConfig::getCfg()
{
return m_cfg ;
}
unsigned NGeoTestConfig::getNumBoundaries()
{
return m_boundaries.size();
}
unsigned NGeoTestConfig::getNumParameters()
{
return m_parameters.size() ;
}
unsigned NGeoTestConfig::getNumNodes()
{
return m_nodes.size() ;
}
unsigned NGeoTestConfig::getNumTransforms()
{
return m_transforms.size() ;
}
bool NGeoTestConfig::getAnalytic()
{
bool analytic = m_analytic.x > 0 ;
return analytic ;
}
bool NGeoTestConfig::getOuterFirst()
{
return m_outerfirst.x > 0 ;
}
bool NGeoTestConfig::isNCSG()
{
return m_csgpath != NULL ;
}
bool NGeoTestConfig::isPmtInBox()
{
return strcmp(m_mode, "PmtInBox") == 0 ;
}
bool NGeoTestConfig::isBoxInBox()
{
return strcmp(m_mode, "BoxInBox") == 0 ;
}
const char* NGeoTestConfig::getMode()
{
return m_mode ;
}
const char* NGeoTestConfig::getPmtPath()
{
return m_pmtpath ;
}
const char* NGeoTestConfig::getCSGPath()
{
return m_csgpath ;
}
const char* NGeoTestConfig::getName()
{
return m_name ;
}
int NGeoTestConfig::getVerbosity()
{
return m_control.x ;
}
void NGeoTestConfig::init(const char* config)
{
configure(config);
}
void NGeoTestConfig::configure(const char* config)
{
LOG(debug) << "NGeoTestConfig::configure" ;
m_config = config ? strdup(config) : DEFAULT_CONFIG ;
m_cfg = BStr::ekv_split(m_config,'_',"="); // element-delim, keyval-delim
for(std::vector<KV>::const_iterator it=m_cfg.begin() ; it!=m_cfg.end() ; it++)
{
LOG(debug)
<< std::setw(20) << it->first
<< " : "
<< it->second
;
Arg_t arg = getArg(it->first.c_str()) ;
set(arg, it->second.c_str());
if(arg == NODE)
{
set(TRANSFORM, NULL); // default transform for each "shape" is identity ("shape" in becoming "node")
}
}
}
NGeoTestConfig::Arg_t NGeoTestConfig::getArg(const char* k)
{
Arg_t arg = UNRECOGNIZED ;
if( strcmp(k,MODE_)==0) arg = MODE ;
else if(strcmp(k,FRAME_)==0) arg = FRAME ;
else if(strcmp(k,BOUNDARY_)==0) arg = BOUNDARY ;
else if(strcmp(k,PARAMETERS_)==0) arg = PARAMETERS ;
else if(strcmp(k,NODE_)==0) arg = NODE ;
else if(strcmp(k,ANALYTIC_)==0) arg = ANALYTIC ;
else if(strcmp(k,DEBUG_)==0) arg = DEBUG ;
else if(strcmp(k,CONTROL_)==0) arg = CONTROL ;
else if(strcmp(k,PMTPATH_)==0) arg = PMTPATH ;
else if(strcmp(k,TRANSFORM_)==0) arg = TRANSFORM ;
else if(strcmp(k,CSGPATH_)==0) arg = CSGPATH ;
else if(strcmp(k,OFFSETS_)==0) arg = OFFSETS ;
else if(strcmp(k,NAME_)==0) arg = NAME ;
else if(strcmp(k,OUTERFIRST_)==0) arg = OUTERFIRST ;
else if(strcmp(k,AUTOCONTAINER_)==0) arg = AUTOCONTAINER ;
else if(strcmp(k,AUTOOBJECT_)==0) arg = AUTOOBJECT ;
else if(strcmp(k,AUTOEMITCONFIG_)==0) arg = AUTOEMITCONFIG ;
else if(strcmp(k,AUTOSEQMAP_)==0) arg = AUTOSEQMAP ;
if(arg == UNRECOGNIZED)
{
LOG(warning) << "NGeoTestConfig::getArg UNRECOGNIZED arg " << k ;
}
return arg ;
}
void NGeoTestConfig::set(Arg_t arg, const char* s)
{
switch(arg)
{
case MODE : setMode(s) ;break;
case FRAME : setFrame(s) ;break;
case BOUNDARY : addBoundary(s) ;break;
case PARAMETERS : addParameters(s) ;break;
case NODE : addNode(s) ;break;
case ANALYTIC : setAnalytic(s) ;break;
case DEBUG : setDebug(s) ;break;
case CONTROL : setControl(s) ;break;
case PMTPATH : setPmtPath(s) ;break;
case TRANSFORM : addTransform(s) ;break;
case CSGPATH : setCsgPath(s) ;break;
case OFFSETS : setOffsets(s) ;break;
case NAME : setName(s) ;break;
case OUTERFIRST : setOuterFirst(s) ;break;
case AUTOCONTAINER : setAutoContainer(s) ;break;
case AUTOOBJECT : setAutoObject(s) ;break;
case AUTOEMITCONFIG : setAutoEmitConfig(s) ;break;
case AUTOSEQMAP : setAutoSeqMap(s) ;break;
case UNRECOGNIZED :
LOG(warning) << "NGeoTestConfig::set WARNING ignoring unrecognized parameter " << s ;
}
}
unsigned NGeoTestConfig::getNumElements()
{
unsigned nbnd = getNumBoundaries();
unsigned nnod = getNumNodes();
unsigned npar = getNumParameters();
unsigned ntra = getNumTransforms();
bool equal = nbnd == npar && nbnd == nnod && ntra == npar ;
if(!equal)
{
LOG(fatal) << "NGeoTestConfig::getNumElements"
<< " ELEMENT MISMATCH IN TEST GEOMETRY CONFIGURATION "
<< " nbnd (boundaries) " << nbnd
<< " nnod (nodes) " << nnod
<< " npar (parameters) " << npar
<< " ntra (transforms) " << ntra
;
}
//assert( equal && "need equal number of boundaries, parameters, transforms and nodes");
//assert(nbnd > 0);
return equal ? nbnd : 0u ;
}
void NGeoTestConfig::dump(const char* msg)
{
unsigned int n = getNumElements();
LOG(info) << msg
<< " config " << m_config
<< " mode " << m_mode
<< " nelem " << n
;
for(unsigned int i=0 ; i < n ; i++)
{
//char csgChar = getNode(i) ;
OpticksCSG_t type = getTypeCode(i) ;
const char* spec = getBoundary(i);
glm::vec4 param = getParameters(i);
std::cout
<< " i " << std::setw(2) << i
<< " type " << std::setw(2) << type
<< " csgName " << std::setw(15) << CSG::Name(type)
<< " param " << std::setw(50) << gformat(param)
<< " spec " << std::setw(30) << spec
<< std::endl
;
}
}
void NGeoTestConfig::setMode(const char* s)
{
m_mode = strdup(s);
}
void NGeoTestConfig::setPmtPath(const char* s)
{
m_pmtpath = strdup(s);
}
void NGeoTestConfig::setCsgPath(const char* s)
{
m_csgpath = strdup(s);
}
void NGeoTestConfig::setName(const char* s)
{
m_name = strdup(s);
}
void NGeoTestConfig::setOffsets(const char* s)
{
BStr::usplit(m_offsets, s, ',' );
}
unsigned NGeoTestConfig::getNumOffsets()
{
return m_offsets.size();
}
unsigned NGeoTestConfig::getOffset(unsigned idx)
{
assert(idx < m_offsets.size());
return m_offsets[idx] ;
}
bool NGeoTestConfig::isStartOfOptiXPrimitive(unsigned nodeIdx )
{
return std::find(m_offsets.begin(), m_offsets.end(), nodeIdx) != m_offsets.end() ;
}
void NGeoTestConfig::setFrame(const char* s)
{
std::string ss(s);
m_frame = givec4(ss);
}
void NGeoTestConfig::setAnalytic(const char* s)
{
std::string ss(s);
m_analytic = givec4(ss);
}
void NGeoTestConfig::setOuterFirst(const char* s)
{
std::string ss(s);
m_outerfirst = givec4(ss);
}
void NGeoTestConfig::setAutoContainer(const char* s)
{
m_autocontainer = strdup(s) ;
}
void NGeoTestConfig::setAutoObject(const char* s)
{
m_autoobject = strdup(s) ;
}
void NGeoTestConfig::setAutoEmitConfig(const char* s)
{
m_autoemitconfig = strdup(s) ;
}
void NGeoTestConfig::setAutoSeqMap(const char* s)
{
m_autoseqmap = strdup(s) ;
}
const char* NGeoTestConfig::getAutoContainer() const
{
return m_autocontainer ;
}
const char* NGeoTestConfig::getAutoObject() const
{
return m_autoobject ;
}
const char* NGeoTestConfig::getAutoEmitConfig() const
{
return m_autoemitconfig ;
}
const char* NGeoTestConfig::getAutoSeqMap() const
{
return m_autoseqmap ;
}
void NGeoTestConfig::setDebug(const char* s)
{
std::string ss(s);
m_debug = gvec4(ss);
}
void NGeoTestConfig::setControl(const char* s)
{
std::string ss(s);
m_control = givec4(ss);
}
void NGeoTestConfig::addParameters(const char* s)
{
std::string ss(s);
m_parameters.push_back(gvec4(ss));
}
void NGeoTestConfig::addTransform(const char* s)
{
std::string ss(s == NULL ? "" : s);
// when adding non-default pop_back first to replace the identity default
if(!ss.empty() && m_transforms.size() > 0)
{
m_transforms.pop_back();
}
m_transforms.push_back(gmat4(ss));
}
void NGeoTestConfig::addBoundary(const char* s)
{
m_boundaries.push_back(s);
}
void NGeoTestConfig::addNode(const char* s)
{
m_nodes.push_back(s);
}
glm::vec4 NGeoTestConfig::getParameters(unsigned int i)
{
unsigned int npars = m_parameters.size();
assert( i < npars ) ;
glm::vec4 param = m_parameters[i] ;
return param ;
}
glm::mat4 NGeoTestConfig::getTransform(unsigned int i)
{
unsigned int ntra = m_transforms.size();
assert( i < ntra ) ;
glm::mat4 trans = m_transforms[i] ;
return trans ;
}
/*
char NGeoTestConfig::getNode(unsigned int i)
{
assert( i < m_nodes.size() );
char nodecode = CSGChar(m_nodes[i].c_str());
return nodecode ;
}
*/
OpticksCSG_t NGeoTestConfig::getTypeCode(unsigned int i)
{
assert( i < m_nodes.size() );
return CSG::TypeCode(m_nodes[i].c_str());
}
std::string NGeoTestConfig::getNodeString(unsigned int i)
{
assert( i < m_nodes.size() );
return m_nodes[i] ;
}
const char* NGeoTestConfig::getBoundary(unsigned int i)
{
assert( i < m_boundaries.size() );
const char* spec = m_boundaries[i].c_str() ;
return spec ;
}
|
{"hexsha": "f475b6f03dd0afb6d673aee5f8f7fe6826a7e3ee", "size": 12497, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "npy/NGeoTestConfig.cpp", "max_stars_repo_name": "hanswenzel/opticks", "max_stars_repo_head_hexsha": "b75b5929b6cf36a5eedeffb3031af2920f75f9f0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 11.0, "max_stars_repo_stars_event_min_datetime": "2020-07-05T02:39:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T18:52:44.000Z", "max_issues_repo_path": "npy/NGeoTestConfig.cpp", "max_issues_repo_name": "hanswenzel/opticks", "max_issues_repo_head_hexsha": "b75b5929b6cf36a5eedeffb3031af2920f75f9f0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "npy/NGeoTestConfig.cpp", "max_forks_repo_name": "hanswenzel/opticks", "max_forks_repo_head_hexsha": "b75b5929b6cf36a5eedeffb3031af2920f75f9f0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 4.0, "max_forks_repo_forks_event_min_datetime": "2020-09-03T20:36:32.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T07:42:21.000Z", "avg_line_length": 24.0326923077, "max_line_length": 114, "alphanum_fraction": 0.6191886053, "num_tokens": 3602}
|
#!/usr/bin/env python3
import pandas as pd
import numpy as np
import math
import os
import sys
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
from jmaloc import MapRegion
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.shapereader as shapereader
import itertools
from utils import collevs
from utils import os_mkdir
from utils import parse_command
from utils import common
def str_rep(inp):
"""データの文字列を処理し数値リストを返す"""
return inp.replace("[", "").replace("]", "").replace(",", "").split()
def read_data(input_filename):
"""AMeDAS csvデータを読み込む
Parameters:
----------
input_filename: str
入力ファイル名
----------
"""
out_lon = list()
out_lat = list()
out_temp = list()
out_u = list()
out_v = list()
out_prep = list()
# データ取得部分
df = pd.read_csv(input_filename)
#print(df)
lon_in = df.loc[:, "lon"]
lat_in = df.loc[:, "lat"]
temp_in = df.loc[:, "temp"]
wd_in = df.loc[:, "windDirection"]
ws_in = df.loc[:, "wind"]
prep_in = df.loc[:, "precipitation1h"]
for lon, lat, temp, wd, ws, prep in zip(lon_in, lat_in, temp_in, wd_in,
ws_in, prep_in):
# 経度・緯度の計算
lon = str_rep(lon)
lat = str_rep(lat)
lon = float(lon[0]) + float(lon[1]) / 60.0
lat = float(lat[0]) + float(lat[1]) / 60.0
#print(lon.strip(), lat.strip(), temp)
# データの保存
out_lon.append(lon)
out_lat.append(lat)
try:
# 気温の計算
temp.isdecimal()
new = str_rep(temp)
if new[1] == "0":
temp = float(new[0])
else:
temp = np.nan
#print(temp)
# データの保存
out_temp.append(temp)
except:
out_temp.append(np.nan)
#
try:
# 風向・風速の計算
wd.isdecimal()
ws.isdecimal()
new_wd = str_rep(wd)
new_ws = str_rep(ws)
if new_wd[1] == "0" and new_ws[1] == "0":
wd = float(new_wd[0]) * 22.5
ws = float(new_ws[0])
else:
wd = np.nan
ws = np.nan
# 東西風、南北風への変換
u = ws * np.cos((270.0 - wd) / 180.0 * np.pi)
v = ws * np.sin((270.0 - wd) / 180.0 * np.pi)
# データの保存
out_u.append(u)
out_v.append(v)
except:
out_u.append(np.nan)
out_v.append(np.nan)
#
try:
# 降水量の計算
prep.isdecimal()
new = str_rep(prep)
if new[1] == "0":
prep = float(new[0])
else:
prep = np.nan
out_prep.append(prep)
except:
out_prep.append(np.nan)
return np.array(out_lon), np.array(out_lat), np.array(out_temp), np.array(
out_u), np.array(out_v), np.array(out_prep)
# ax: cartopyを呼び出した際のaxes
def add_pref(ax,
linestyle='-',
facecolor='none',
edgecolor='k',
linewidth=0.8):
# 10mの解像度のデータ
shpfilename = shapereader.natural_earth(resolution='10m',
category='cultural',
name='admin_1_states_provinces')
#
# 都道府県のみ取得
provinces = shapereader.Reader(shpfilename).records()
provinces_of_japan = filter(
lambda province: province.attributes['admin'] == 'Japan', provinces)
#
# 都道府県境の追加
for province in provinces_of_japan:
#print(province.attributes['name'])
geometry = province.geometry
ax.add_geometries([geometry],
ccrs.PlateCarree(),
facecolor=facecolor,
edgecolor=edgecolor,
linewidth=linewidth,
linestyle=linestyle)
def draw(lons,
lats,
d,
output_filename="test.png",
opt_mapcolor=False,
opt_pref=False,
opt_markerlabel=False,
title=None,
area=None):
"""cartopyを用いて作図を行う
Parameters:
----------
lons: ndarray
経度データ
lats: ndarray
緯度データ
d: ndarray
降水量データ
output_filename: str
出力ファイル名
opt_mapcolor: bool
True: 陸・海・湖を塗り分けて描く
False: 海岸線を描く
opt_pref: bool
都道府県境を描くかどうか
opt_markerlabel: bool
マーカーの隣に降水量を表示するかどうか
title: str
図のタイトル(Noneなら描かない)
area: str
図を描く領域
----------
"""
# プロット領域の作成
fig = plt.figure(figsize=(18, 12))
#
# MapRegion Classの初期化
region = MapRegion(area)
# Map.regionの変数を取得
lon_step = region.lon_step # 経度線を描く間隔
lon_min = region.lon_min # 経度範囲下限
lon_max = region.lon_max # 経度範囲上限
lat_step = region.lat_step # 緯度線を描く間隔
lat_min = region.lat_min # 緯度範囲下限
lat_max = region.lat_max # 緯度範囲上限
if area == "Japan":
ms = 1 # マーカーサイズ
length = 4 # 矢羽のサイズ
lw = 0.6 # 矢羽の幅
else:
ms = 6 # マーカーサイズ
length = 7 # 矢羽のサイズ
lw = 1.5 # 矢羽の幅
#
# cartopy呼び出し
ax = fig.add_axes((0.1, 0.3, 0.8, 0.6), projection=ccrs.PlateCarree())
#ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.set_extent([lon_min, lon_max, lat_min, lat_max]) # 領域の限定
# 経度、緯度線を描く
xticks = np.arange(-180, 180, lon_step)
yticks = np.arange(-90, 90, lat_step)
gl = ax.gridlines(crs=ccrs.PlateCarree(),
draw_labels=True,
linewidth=1,
linestyle=':',
color='k',
alpha=0.8)
gl.xlocator = mticker.FixedLocator(xticks) # 経度線
gl.ylocator = mticker.FixedLocator(yticks) # 緯度線
gl.top_labels = False # 上側の目盛り線ラベルを描かない
gl.right_labels = False # 下側の目盛り線ラベルを描かない
# 海岸線を描く
if opt_mapcolor:
# 陸・海・湖を塗り分けて描く
ax.add_feature(cfeature.LAND, color='darkseagreen')
ax.add_feature(cfeature.OCEAN)
#ax.add_feature(cfeature.OCEAN, color='powderblue')
ax.add_feature(cfeature.COASTLINE)
#ax.add_feature(cfeature.COASTLINE, linewidth=0.8)
ax.add_feature(cfeature.LAKES)
else:
ax.coastlines(resolution='10m', color='k', linewidth=0.8)
#
# 都道府県境を描く
if opt_pref:
add_pref(ax, linestyle='-', facecolor='none', linewidth=0.8)
#
clevs = [20., 50., 100., 200., 300., 400., 600., 800., 2000.]
#clevs = [0.5, 10., 20., 50., 100., 200., 300., 400., 2000.]
#clevs = [0.5, 10., 20., 50., 80., 100., 120., 150., 2000.]
ccols = [
"lavender", "paleturquoise", "dodgerblue", "b", "gold", "darkorange",
"r", "firebrick"
]
# collevsクラスの初期化(降水量の範囲をclevs、色をccolsで与える)
t2c = collevs(clevs=clevs, ccols=ccols)
#
# マーカーとテキストをプロット
for xc, yc, dc in zip(lons, lats, d):
if math.isnan(dc):
print("Warn ", xc, yc, dc)
else:
c = t2c.conv(dc)
ax.plot(xc, yc, marker='o', color=c, markersize=ms)
if opt_markerlabel:
if xc >= lon_min and xc <= lon_max and yc >= lat_min and yc <= lat_max:
ax.text(xc + 0.03, yc - 0.02, str(dc), color=c, fontsize=8)
# タイトル
if title is not None:
plt.title(title, size=24)
#fig.suptitle(title, size=24)
# カラーバーを付ける
t2c.colorbar(fig, anchor=(0.30, 0.25), size=(0.35, 0.02))
# ファイルへの書き出し
plt.savefig(output_filename, dpi=300, bbox_inches='tight')
plt.close()
def main(tinfof=None):
"""指定された時刻データを取得
Parameters:
----------
tinfof: str
ファイル名の一部に用いる時刻
(形式:20210312161000)
----------
"""
if tinfof is not None:
# 入力ファイル名
input_filename = tinfof + ".csv"
# データの取得
lons, lats, temp, u, v, prep = read_data(input_filename)
print(lons.shape, lats.shape, temp.shape, u.shape, v.shape, prep.shape)
#
return lons, lats, temp, u, v, prep
if __name__ == '__main__':
# オプションの読み込み
args = parse_command(sys.argv, opt_lab=True)
# 開始・終了時刻
time_sta = pd.to_datetime(args.time_sta)
time_end = pd.to_datetime(args.time_end)
# 作図する領域
area = args.sta
# 出力ディレクトリ名
output_dir = args.output_dir
# 降水量を数字で表示するかどうか
opt_markerlabel = args.mlabel
# 出力ディレクトリ作成
os_mkdir(output_dir)
# データの時間間隔
time_step = timedelta(hours=1)
time = time_sta
ofirst = True
while True:
if time <= time_end:
tinfo = time.strftime("%Y/%m/%d %H:%M:%SJST")
tinfof = time.strftime("%Y%m%d%H%M%S")
print(tinfo)
# データ読み込み
lons, lats, t_i, u_i, v_i, pr_i = main(tinfof)
if ofirst:
prep = pr_i
ofirst = False
else:
prep = prep + pr_i
# 出力ファイル名
output_filename = os.path.join(output_dir,
area + "_cumrain_" + tinfof + ".png")
# 作図
draw(lons,
lats,
prep,
output_filename,
title=tinfo,
area=area,
opt_pref=True,
opt_markerlabel=opt_markerlabel,
opt_mapcolor=True)
else:
break
time = time + time_step
|
{"hexsha": "8c430323502e90f07e8d2d29b372183a8cf06560", "size": 9540, "ext": "py", "lang": "Python", "max_stars_repo_path": "jma_ame_nrt/cartopy_jma_cumrain.py", "max_stars_repo_name": "yyousuke/jma_draw", "max_stars_repo_head_hexsha": "e8e24521e494ec7ae26be211bfc8ddc62bb73899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "jma_ame_nrt/cartopy_jma_cumrain.py", "max_issues_repo_name": "yyousuke/jma_draw", "max_issues_repo_head_hexsha": "e8e24521e494ec7ae26be211bfc8ddc62bb73899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "jma_ame_nrt/cartopy_jma_cumrain.py", "max_forks_repo_name": "yyousuke/jma_draw", "max_forks_repo_head_hexsha": "e8e24521e494ec7ae26be211bfc8ddc62bb73899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.734939759, "max_line_length": 87, "alphanum_fraction": 0.5244234801, "include": true, "reason": "import numpy", "num_tokens": 3187}
|
#redirect Institute of Transportation Studies
|
{"hexsha": "7d7f54ec4509a0541569f04d7411f6d012d0ddea", "size": 46, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "lab/davisWiki/Institute_for_Transportation_Studies.f", "max_stars_repo_name": "voflo/Search", "max_stars_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab/davisWiki/Institute_for_Transportation_Studies.f", "max_issues_repo_name": "voflo/Search", "max_issues_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab/davisWiki/Institute_for_Transportation_Studies.f", "max_forks_repo_name": "voflo/Search", "max_forks_repo_head_hexsha": "55088b2fe6a9d6c90590f090542e0c0e3c188c7d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0, "max_line_length": 45, "alphanum_fraction": 0.8695652174, "num_tokens": 7}
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import ring_theory.witt_vector.basic
/-!
# Teichmüller lifts
This file defines `witt_vector.teichmuller`, a monoid hom `R →* 𝕎 R`, which embeds `r : R` as the
`0`-th component of a Witt vector whose other coefficients are `0`.
## Main declarations
- `witt_vector.teichmuller`: the Teichmuller map.
- `witt_vector.map_teichmuller`: `witt_vector.teichmuller` is a natural transformation.
- `witt_vector.ghost_component_teichmuller`:
the `n`-th ghost component of `witt_vector.teichmuller p r` is `r ^ p ^ n`.
## References
* [Hazewinkel, *Witt Vectors*][Haze09]
* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]
-/
namespace witt_vector
open mv_polynomial
variables (p : ℕ) {R S : Type*} [hp : fact p.prime] [comm_ring R] [comm_ring S]
local notation `𝕎` := witt_vector p -- type as `\bbW`
/--
The underlying function of the monoid hom `witt_vector.teichmuller`.
The `0`-th coefficient of `teichmuller_fun p r` is `r`, and all others are `0`.
-/
def teichmuller_fun (r : R) : 𝕎 R :=
⟨p, λ n, if n = 0 then r else 0⟩
/-!
## `teichmuller` is a monoid homomorphism
On ghost components, it is clear that `teichmuller_fun` is a monoid homomorphism.
But in general the ghost map is not injective.
We follow the same strategy as for proving that the ring operations on `𝕎 R`
satisfy the ring axioms.
1. We first prove it for rings `R` where `p` is invertible,
because then the ghost map is in fact an isomorphism.
2. After that, we derive the result for `mv_polynomial R ℤ`,
3. and from that we can prove the result for arbitrary `R`.
-/
include hp
private lemma ghost_component_teichmuller_fun (r : R) (n : ℕ) :
ghost_component n (teichmuller_fun p r) = r ^ p ^ n :=
begin
rw [ghost_component_apply, aeval_witt_polynomial, finset.sum_eq_single 0,
pow_zero, one_mul, tsub_zero],
{ refl },
{ intros i hi h0,
convert mul_zero _, convert zero_pow _,
{ cases i, { contradiction }, { refl } },
{ exact pow_pos hp.1.pos _ } },
{ rw finset.mem_range, intro h, exact (h (nat.succ_pos n)).elim }
end
private lemma map_teichmuller_fun (f : R →+* S) (r : R) :
map f (teichmuller_fun p r) = teichmuller_fun p (f r) :=
by { ext n, cases n, { refl }, { exact f.map_zero } }
private lemma teichmuller_mul_aux₁ (x y : mv_polynomial R ℚ) :
teichmuller_fun p (x * y) = teichmuller_fun p x * teichmuller_fun p y :=
begin
apply (ghost_map.bijective_of_invertible p (mv_polynomial R ℚ)).1,
rw ring_hom.map_mul,
ext1 n,
simp only [pi.mul_apply, ghost_map_apply, ghost_component_teichmuller_fun, mul_pow],
end
private lemma teichmuller_mul_aux₂ (x y : mv_polynomial R ℤ) :
teichmuller_fun p (x * y) = teichmuller_fun p x * teichmuller_fun p y :=
begin
refine map_injective (mv_polynomial.map (int.cast_ring_hom ℚ))
(mv_polynomial.map_injective _ int.cast_injective) _,
simp only [teichmuller_mul_aux₁, map_teichmuller_fun, ring_hom.map_mul]
end
/-- The Teichmüller lift of an element of `R` to `𝕎 R`.
The `0`-th coefficient of `teichmuller p r` is `r`, and all others are `0`.
This is a monoid homomorphism. -/
def teichmuller : R →* 𝕎 R :=
{ to_fun := teichmuller_fun p,
map_one' :=
begin
ext ⟨⟩,
{ rw one_coeff_zero, refl },
{ rw one_coeff_eq_of_pos _ _ _ (nat.succ_pos n), refl }
end,
map_mul' :=
begin
intros x y,
rcases counit_surjective R x with ⟨x, rfl⟩,
rcases counit_surjective R y with ⟨y, rfl⟩,
simp only [← map_teichmuller_fun, ← ring_hom.map_mul, teichmuller_mul_aux₂],
end }
@[simp] lemma teichmuller_coeff_zero (r : R) :
(teichmuller p r).coeff 0 = r := rfl
@[simp] lemma teichmuller_coeff_pos (r : R) :
∀ (n : ℕ) (hn : 0 < n), (teichmuller p r).coeff n = 0
| (n+1) _ := rfl.
@[simp] lemma teichmuller_zero : teichmuller p (0:R) = 0 :=
by ext ⟨⟩; { rw zero_coeff, refl }
/-- `teichmuller` is a natural transformation. -/
@[simp] lemma map_teichmuller (f : R →+* S) (r : R) :
map f (teichmuller p r) = teichmuller p (f r) :=
map_teichmuller_fun _ _ _
/-- The `n`-th ghost component of `teichmuller p r` is `r ^ p ^ n`. -/
@[simp] lemma ghost_component_teichmuller (r : R) (n : ℕ) :
ghost_component n (teichmuller p r) = r ^ p ^ n :=
ghost_component_teichmuller_fun _ _ _
end witt_vector
|
{"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/witt_vector/teichmuller.lean"}
|
[STATEMENT]
lemma dense_accessible_frontier_points:
fixes S :: "'a::{complete_space,real_normed_vector} set"
assumes "open S" and opeSV: "openin (top_of_set (frontier S)) V" and "V \<noteq> {}"
obtains g where "arc g" "g ` {0..<1} \<subseteq> S" "pathstart g \<in> S" "pathfinish g \<in> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain z where "z \<in> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>z. z \<in> V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>V \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
using this:
V \<noteq> {}
goal (1 subgoal):
1. (\<And>z. z \<in> V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z \<in> V
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<in> V
[PROOF STEP]
obtain r where "r > 0" and r: "ball z r \<inter> frontier S \<subseteq> V"
[PROOF STATE]
proof (prove)
using this:
z \<in> V
goal (1 subgoal):
1. (\<And>r. \<lbrakk>0 < r; ball z r \<inter> frontier S \<subseteq> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis openin_contains_ball opeSV)
[PROOF STATE]
proof (state)
this:
0 < r
ball z r \<inter> frontier S \<subseteq> V
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < r
ball z r \<inter> frontier S \<subseteq> V
[PROOF STEP]
have "z \<in> frontier S"
[PROOF STATE]
proof (prove)
using this:
0 < r
ball z r \<inter> frontier S \<subseteq> V
goal (1 subgoal):
1. z \<in> frontier S
[PROOF STEP]
using \<open>z \<in> V\<close> opeSV openin_contains_ball
[PROOF STATE]
proof (prove)
using this:
0 < r
ball z r \<inter> frontier S \<subseteq> V
z \<in> V
openin (top_of_set (frontier S)) V
openin (top_of_set ?T) ?S = (?S \<subseteq> ?T \<and> (\<forall>x\<in>?S. \<exists>e>0. ball x e \<inter> ?T \<subseteq> ?S))
goal (1 subgoal):
1. z \<in> frontier S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z \<in> frontier S
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<in> frontier S
[PROOF STEP]
have "z \<in> closure S" "z \<notin> S"
[PROOF STATE]
proof (prove)
using this:
z \<in> frontier S
goal (1 subgoal):
1. z \<in> closure S &&& z \<notin> S
[PROOF STEP]
by (simp_all add: frontier_def assms interior_open)
[PROOF STATE]
proof (state)
this:
z \<in> closure S
z \<notin> S
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
with \<open>r > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < r
z \<in> closure S
z \<notin> S
[PROOF STEP]
have "infinite (S \<inter> ball z r)"
[PROOF STATE]
proof (prove)
using this:
0 < r
z \<in> closure S
z \<notin> S
goal (1 subgoal):
1. infinite (S \<inter> ball z r)
[PROOF STEP]
by (auto simp: closure_def islimpt_eq_infinite_ball)
[PROOF STATE]
proof (state)
this:
infinite (S \<inter> ball z r)
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infinite (S \<inter> ball z r)
[PROOF STEP]
obtain y where "y \<in> S" and y: "y \<in> ball z r"
[PROOF STATE]
proof (prove)
using this:
infinite (S \<inter> ball z r)
goal (1 subgoal):
1. (\<And>y. \<lbrakk>y \<in> S; y \<in> ball z r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using infinite_imp_nonempty
[PROOF STATE]
proof (prove)
using this:
infinite (S \<inter> ball z r)
infinite ?S \<Longrightarrow> ?S \<noteq> {}
goal (1 subgoal):
1. (\<And>y. \<lbrakk>y \<in> S; y \<in> ball z r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
y \<in> S
y \<in> ball z r
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<in> S
y \<in> ball z r
[PROOF STEP]
have "y \<notin> frontier S"
[PROOF STATE]
proof (prove)
using this:
y \<in> S
y \<in> ball z r
goal (1 subgoal):
1. y \<notin> frontier S
[PROOF STEP]
by (meson \<open>open S\<close> disjoint_iff_not_equal frontier_disjoint_eq)
[PROOF STATE]
proof (state)
this:
y \<notin> frontier S
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "y \<noteq> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. y \<noteq> z
[PROOF STEP]
using \<open>y \<in> S\<close> \<open>z \<notin> S\<close>
[PROOF STATE]
proof (prove)
using this:
y \<in> S
z \<notin> S
goal (1 subgoal):
1. y \<noteq> z
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
y \<noteq> z
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "path_connected(ball z r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. path_connected (ball z r)
[PROOF STEP]
by (simp add: convex_imp_path_connected)
[PROOF STATE]
proof (state)
this:
path_connected (ball z r)
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
with y \<open>r > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
y \<in> ball z r
0 < r
path_connected (ball z r)
[PROOF STEP]
obtain g where "arc g" and pig: "path_image g \<subseteq> ball z r"
and g: "pathstart g = y" "pathfinish g = z"
[PROOF STATE]
proof (prove)
using this:
y \<in> ball z r
0 < r
path_connected (ball z r)
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; path_image g \<subseteq> ball z r; pathstart g = y; pathfinish g = z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>y \<noteq> z\<close>
[PROOF STATE]
proof (prove)
using this:
y \<in> ball z r
0 < r
path_connected (ball z r)
y \<noteq> z
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; path_image g \<subseteq> ball z r; pathstart g = y; pathfinish g = z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (force simp: path_connected_arcwise)
[PROOF STATE]
proof (state)
this:
arc g
path_image g \<subseteq> ball z r
pathstart g = y
pathfinish g = z
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "continuous_on {0..1} g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. continuous_on {0..1} g
[PROOF STEP]
using \<open>arc g\<close> arc_imp_path path_def
[PROOF STATE]
proof (prove)
using this:
arc g
arc ?g \<Longrightarrow> path ?g
path ?g = continuous_on {0..1} ?g
goal (1 subgoal):
1. continuous_on {0..1} g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
continuous_on {0..1} g
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
continuous_on {0..1} g
[PROOF STEP]
have "compact (g -` frontier S \<inter> {0..1})"
[PROOF STATE]
proof (prove)
using this:
continuous_on {0..1} g
goal (1 subgoal):
1. compact (g -` frontier S \<inter> {0..1})
[PROOF STEP]
by (simp add: bounded_Int closed_Diff closed_vimage_Int compact_eq_bounded_closed)
[PROOF STATE]
proof (state)
this:
compact (g -` frontier S \<inter> {0..1})
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
compact (g -` frontier S \<inter> {0..1})
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "g -` frontier S \<inter> {0..1} \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. g -` frontier S \<inter> {0..1} \<noteq> {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. g -` frontier S \<inter> {0..1} \<noteq> {}
[PROOF STEP]
have "\<exists>r. r \<in> g -` frontier S \<and> r \<in> {0..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>r. r \<in> g -` frontier S \<and> r \<in> {0..1}
[PROOF STEP]
by (metis \<open>z \<in> frontier S\<close> g(2) imageE path_image_def pathfinish_in_path_image vimageI2)
[PROOF STATE]
proof (state)
this:
\<exists>r. r \<in> g -` frontier S \<and> r \<in> {0..1}
goal (1 subgoal):
1. g -` frontier S \<inter> {0..1} \<noteq> {}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>r. r \<in> g -` frontier S \<and> r \<in> {0..1}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>r. r \<in> g -` frontier S \<and> r \<in> {0..1}
goal (1 subgoal):
1. g -` frontier S \<inter> {0..1} \<noteq> {}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g -` frontier S \<inter> {0..1} \<noteq> {}
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
g -` frontier S \<inter> {0..1} \<noteq> {}
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
compact (g -` frontier S \<inter> {0..1})
g -` frontier S \<inter> {0..1} \<noteq> {}
[PROOF STEP]
obtain t where gt: "g t \<in> frontier S" and "0 \<le> t" "t \<le> 1"
and t: "\<And>u. \<lbrakk>g u \<in> frontier S; 0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> u"
[PROOF STATE]
proof (prove)
using this:
compact (g -` frontier S \<inter> {0..1})
g -` frontier S \<inter> {0..1} \<noteq> {}
goal (1 subgoal):
1. (\<And>t. \<lbrakk>g t \<in> frontier S; 0 \<le> t; t \<le> 1; \<And>u. \<lbrakk>g u \<in> frontier S; 0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> u\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (force simp: dest!: compact_attains_inf)
[PROOF STATE]
proof (state)
this:
g t \<in> frontier S
0 \<le> t
t \<le> 1
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
g t \<in> frontier S
0 \<le> t
t \<le> 1
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "t \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. t \<noteq> 0
[PROOF STEP]
by (metis \<open>y \<notin> frontier S\<close> g(1) gt pathstart_def)
[PROOF STATE]
proof (state)
this:
t \<noteq> 0
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
g t \<in> frontier S
0 \<le> t
t \<le> 1
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
t \<noteq> 0
[PROOF STEP]
have t01: "0 < t" "t \<le> 1"
[PROOF STATE]
proof (prove)
using this:
g t \<in> frontier S
0 \<le> t
t \<le> 1
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
t \<noteq> 0
goal (1 subgoal):
1. 0 < t &&& t \<le> 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < t
t \<le> 1
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "V \<subseteq> frontier S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. V \<subseteq> frontier S
[PROOF STEP]
using opeSV openin_contains_ball
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set (frontier S)) V
openin (top_of_set ?T) ?S = (?S \<subseteq> ?T \<and> (\<forall>x\<in>?S. \<exists>e>0. ball x e \<inter> ?T \<subseteq> ?S))
goal (1 subgoal):
1. V \<subseteq> frontier S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
V \<subseteq> frontier S
goal (1 subgoal):
1. (\<And>g. \<lbrakk>arc g; g ` {0..<1} \<subseteq> S; pathstart g \<in> S; pathfinish g \<in> V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (4 subgoals):
1. arc ?g
2. ?g ` {0..<1} \<subseteq> S
3. pathstart ?g \<in> S
4. pathfinish ?g \<in> V
[PROOF STEP]
show "arc (subpath 0 t g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. arc (subpath 0 t g)
[PROOF STEP]
by (simp add: \<open>0 \<le> t\<close> \<open>t \<le> 1\<close> \<open>arc g\<close> \<open>t \<noteq> 0\<close> arc_subpath_arc)
[PROOF STATE]
proof (state)
this:
arc (subpath 0 t g)
goal (3 subgoals):
1. subpath 0 t g ` {0..<1} \<subseteq> S
2. pathstart (subpath 0 t g) \<in> S
3. pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
have "g 0 \<in> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. g 0 \<in> S
[PROOF STEP]
by (metis \<open>y \<in> S\<close> g(1) pathstart_def)
[PROOF STATE]
proof (state)
this:
g 0 \<in> S
goal (3 subgoals):
1. subpath 0 t g ` {0..<1} \<subseteq> S
2. pathstart (subpath 0 t g) \<in> S
3. pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g 0 \<in> S
[PROOF STEP]
show "pathstart (subpath 0 t g) \<in> S"
[PROOF STATE]
proof (prove)
using this:
g 0 \<in> S
goal (1 subgoal):
1. pathstart (subpath 0 t g) \<in> S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pathstart (subpath 0 t g) \<in> S
goal (2 subgoals):
1. subpath 0 t g ` {0..<1} \<subseteq> S
2. pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
have "g t \<in> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. g t \<in> V
[PROOF STEP]
by (metis IntI atLeastAtMost_iff gt image_eqI path_image_def pig r subsetCE \<open>0 \<le> t\<close> \<open>t \<le> 1\<close>)
[PROOF STATE]
proof (state)
this:
g t \<in> V
goal (2 subgoals):
1. subpath 0 t g ` {0..<1} \<subseteq> S
2. pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g t \<in> V
[PROOF STEP]
show "pathfinish (subpath 0 t g) \<in> V"
[PROOF STATE]
proof (prove)
using this:
g t \<in> V
goal (1 subgoal):
1. pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pathfinish (subpath 0 t g) \<in> V
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
pathfinish (subpath 0 t g) \<in> V
[PROOF STEP]
have "inj_on (subpath 0 t g) {0..1}"
[PROOF STATE]
proof (prove)
using this:
pathfinish (subpath 0 t g) \<in> V
goal (1 subgoal):
1. inj_on (subpath 0 t g) {0..1}
[PROOF STEP]
using t01 \<open>arc (subpath 0 t g)\<close> arc_imp_inj_on
[PROOF STATE]
proof (prove)
using this:
pathfinish (subpath 0 t g) \<in> V
0 < t
t \<le> 1
arc (subpath 0 t g)
arc ?g \<Longrightarrow> inj_on ?g {0..1}
goal (1 subgoal):
1. inj_on (subpath 0 t g) {0..1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
inj_on (subpath 0 t g) {0..1}
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inj_on (subpath 0 t g) {0..1}
[PROOF STEP]
have "subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}"
[PROOF STATE]
proof (prove)
using this:
inj_on (subpath 0 t g) {0..1}
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}
[PROOF STEP]
by (force simp: dest: inj_onD)
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
have False if "subpath 0 t g ` ({0..<1}) - S \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. False
[PROOF STEP]
have contg: "continuous_on {0..1} g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. continuous_on {0..1} g
[PROOF STEP]
using \<open>arc g\<close>
[PROOF STATE]
proof (prove)
using this:
arc g
goal (1 subgoal):
1. continuous_on {0..1} g
[PROOF STEP]
by (auto simp: arc_def path_def)
[PROOF STATE]
proof (state)
this:
continuous_on {0..1} g
goal (1 subgoal):
1. False
[PROOF STEP]
have "subpath 0 t g ` {0..<1} \<inter> frontier S \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<inter> frontier S \<noteq> {}
[PROOF STEP]
proof (rule connected_Int_frontier [OF _ _ that])
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. connected (subpath 0 t g ` {0..<1})
2. subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}
[PROOF STEP]
show "connected (subpath 0 t g ` {0..<1})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. connected (subpath 0 t g ` {0..<1})
[PROOF STEP]
proof (rule connected_continuous_image)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. continuous_on {0..<1} (subpath 0 t g)
2. connected {0..<1}
[PROOF STEP]
show "continuous_on {0..<1} (subpath 0 t g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. continuous_on {0..<1} (subpath 0 t g)
[PROOF STEP]
by (meson \<open>arc (subpath 0 t g)\<close> arc_def atLeastLessThan_subseteq_atLeastAtMost_iff continuous_on_subset order_refl path_def)
[PROOF STATE]
proof (state)
this:
continuous_on {0..<1} (subpath 0 t g)
goal (1 subgoal):
1. connected {0..<1}
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
connected (subpath 0 t g ` {0..<1})
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}
[PROOF STEP]
show "subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}
[PROOF STEP]
using \<open>y \<in> S\<close> g(1)
[PROOF STATE]
proof (prove)
using this:
y \<in> S
pathstart g = y
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}
[PROOF STEP]
by (force simp: subpath_def image_def pathstart_def)
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} \<inter> S \<noteq> {}
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} \<inter> frontier S \<noteq> {}
goal (1 subgoal):
1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
subpath 0 t g ` {0..<1} \<inter> frontier S \<noteq> {}
[PROOF STEP]
obtain x where "x \<in> subpath 0 t g ` {0..<1}" "x \<in> frontier S"
[PROOF STATE]
proof (prove)
using this:
subpath 0 t g ` {0..<1} \<inter> frontier S \<noteq> {}
goal (1 subgoal):
1. (\<And>x. \<lbrakk>x \<in> subpath 0 t g ` {0..<1}; x \<in> frontier S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> subpath 0 t g ` {0..<1}
x \<in> frontier S
goal (1 subgoal):
1. False
[PROOF STEP]
with t01 \<open>0 \<le> t\<close> mult_le_one t
[PROOF STATE]
proof (chain)
picking this:
0 < t
t \<le> 1
0 \<le> t
\<lbrakk>?a \<le> (1::?'a); (0::?'a) \<le> ?b; ?b \<le> (1::?'a)\<rbrakk> \<Longrightarrow> ?a * ?b \<le> (1::?'a)
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
x \<in> subpath 0 t g ` {0..<1}
x \<in> frontier S
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
0 < t
t \<le> 1
0 \<le> t
\<lbrakk>?a \<le> (1::?'a); (0::?'a) \<le> ?b; ?b \<le> (1::?'a)\<rbrakk> \<Longrightarrow> ?a * ?b \<le> (1::?'a)
\<lbrakk>g ?u \<in> frontier S; 0 \<le> ?u; ?u \<le> 1\<rbrakk> \<Longrightarrow> t \<le> ?u
x \<in> subpath 0 t g ` {0..<1}
x \<in> frontier S
goal (1 subgoal):
1. False
[PROOF STEP]
by (fastforce simp: subpath_def)
[PROOF STATE]
proof (state)
this:
False
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} - S \<noteq> {} \<Longrightarrow> False
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
subpath 0 t g ` {0..<1} - S \<noteq> {} \<Longrightarrow> False
[PROOF STEP]
have "subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S"
[PROOF STATE]
proof (prove)
using this:
subpath 0 t g ` {0..<1} - S \<noteq> {} \<Longrightarrow> False
goal (1 subgoal):
1. subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S
[PROOF STEP]
using subsetD
[PROOF STATE]
proof (prove)
using this:
subpath 0 t g ` {0..<1} - S \<noteq> {} \<Longrightarrow> False
\<lbrakk>?A \<subseteq> ?B; ?c \<in> ?A\<rbrakk> \<Longrightarrow> ?c \<in> ?B
goal (1 subgoal):
1. subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}
subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S
[PROOF STEP]
show "subpath 0 t g ` {0..<1} \<subseteq> S"
[PROOF STATE]
proof (prove)
using this:
subpath 0 t g ` {0..<1} \<subseteq> subpath 0 t g ` {0..1} - {subpath 0 t g 1}
subpath 0 t g ` {0..1} - {subpath 0 t g 1} \<subseteq> S
goal (1 subgoal):
1. subpath 0 t g ` {0..<1} \<subseteq> S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
subpath 0 t g ` {0..<1} \<subseteq> S
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
thesis
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 10377, "file": null, "length": 114}
|
import numpy as np
import scipy as sp
import scipy.spatial.distance
import matplotlib.pyplot as plt
from keras import backend as K
from ViewMNIST import PlotResult
def GetFeature(x, functor, saveIdx, normalize=False):
embedding = None
try:
layer_outs = functor([x, 0.])
embedding = layer_outs[saveIdx]
if (normalize == True):
norm = np.sqrt(embedding[:,0]*embedding[:,0] + embedding[:,1]*embedding[:,1])
norm[norm == 0] = np.finfo(float).eps
embedding[:,0] = embedding[:,0] / norm
embedding[:,1] = embedding[:,1] / norm
except OSError:
print('Feat error')
return embedding
def GetFeatMatrix(X, model, saveIdx, normalize=False):
inp = model.get_input_at(0) # input placeholder
outputs = [layer.output for layer in model.layers] # all layer outputs
#outputNames = [layer.name for layer in model.layers]
functor = K.function([inp]+ [K.learning_phase()], outputs ) # evaluation function
embedding = GetFeature(X, functor, saveIdx, normalize)
return embedding
def GetRank1Accuracy(probe, pLabel, gallery, gLabel, galleryClr, base_network, saveIdx, saveFigName=None, normalize = False):
probeFeat = GetFeatMatrix(probe, base_network, saveIdx, normalize)
galleryFeat = GetFeatMatrix(gallery, base_network, saveIdx, normalize)
dist = sp.spatial.distance.cdist(galleryFeat, probeFeat)
TP = 0
for i in range(0,dist.shape[1]):
minIdx = np.argmin(dist[:,i])
if pLabel[i] == gLabel[minIdx]:
TP += 1
rank1 = (TP/dist.shape[1] * 100)
if (saveFigName is not None):
PlotResult(galleryClr, galleryFeat, False, saveFigName)
return rank1
|
{"hexsha": "6cb8c3fccaf0a289c26128905937527c1d3f7bf6", "size": 1780, "ext": "py", "lang": "Python", "max_stars_repo_path": "ReIDHelpers.py", "max_stars_repo_name": "psiva7/MNISTTriplet", "max_stars_repo_head_hexsha": "695897b5229387a092b69b5de17dbd996ca2d899", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ReIDHelpers.py", "max_issues_repo_name": "psiva7/MNISTTriplet", "max_issues_repo_head_hexsha": "695897b5229387a092b69b5de17dbd996ca2d899", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ReIDHelpers.py", "max_forks_repo_name": "psiva7/MNISTTriplet", "max_forks_repo_head_hexsha": "695897b5229387a092b69b5de17dbd996ca2d899", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0833333333, "max_line_length": 125, "alphanum_fraction": 0.6404494382, "include": true, "reason": "import numpy,import scipy", "num_tokens": 445}
|
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
from functools import reduce
import sys
import subprocess
import argparse
import pandas as pd
from statistics import mean, variance, stdev, median_grouped
# ref. https://qiita.com/qsnsr123/items/325d21621cfe9e553c17
plt.rcParams['font.family'] ='sans-serif'
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.rcParams['xtick.major.width'] = 1.0
plt.rcParams['ytick.major.width'] = 1.0
plt.rcParams['font.size'] = 9
plt.rcParams['xtick.labelsize'] = 7
plt.rcParams['ytick.labelsize'] = 8
plt.rcParams['axes.linewidth'] = 1.0
# plt.gca().xaxis.get_major_formatter().set_useOffset(True)
# plt.locator_params(axis='x',nbins=3)
# plt.gca().yaxis.set_tick_params(which='both', direction='in',bottom=True, top=True, left=True, right=True)
func_types =[
"Publication_publish",
"Publisher_publish",
"Publication_enqueueMessage",
"SubscriptionQueue_push",
"SubscriptionQueue_call_before_callback",
"SubscriptionQueue_call_after_callback",
"TransportTCP_write",
"TransportTCP_read",
"accept",
"connect",
"bind",
]
# 2 1613531009784539434 11345 11361 2 2
def collect(name):
node = dict()
node["Publication_publish"] = dict()
node["Publisher_publish"] = dict()
node["Publication_enqueueMessage"] = dict()
node["SubscriptionQueue_push"] = dict()
node["SubscriptionQueue_call_before_callback"] = dict()
node["SubscriptionQueue_call_after_callback"] = dict()
node["TransportTCP_write"] = dict()
node["TransportTCP_read"] = dict()
node["socket"] = dict()
node["port"] = list()
with open(name) as f:
for _l in f.readlines():
l = _l.split()
f_type = func_types[int(l[0])]
seq1 = int(l[4])
seq2 = int(l[5])
time = int(l[1])
pid = int(l[2])
tid = int(l[3])
name = l[6]
if f_type == "Publisher_publish":
node["Publisher_publish"][seq2] = dict()
node["Publisher_publish"][seq2]["time"] = time
elif f_type == "Publication_publish":
node["Publication_publish"][seq2] = dict()
node["Publication_publish"][seq2]["time"] = time
elif f_type == "Publication_enqueueMessage":
node["Publication_enqueueMessage"][seq1] = dict()
node["Publication_enqueueMessage"][seq1]["time"] = time
node["Publication_enqueueMessage"][seq1]["seq"] = seq2
elif f_type == "SubscriptionQueue_push":
node["SubscriptionQueue_push"][seq1] = dict()
node["SubscriptionQueue_push"][seq1]["time"] = time
node["SubscriptionQueue_push"][seq1]["seq"] = seq2
elif f_type == "SubscriptionQueue_call_before_callback":
node["SubscriptionQueue_call_before_callback"][seq1] = dict()
node["SubscriptionQueue_call_before_callback"][seq1]["time"] = time
node["SubscriptionQueue_call_before_callback"][seq1]["seq"] = seq2
node["SubscriptionQueue_call_before_callback"][seq1]["name"] = name
elif f_type == "SubscriptionQueue_call_after_callback":
node["SubscriptionQueue_call_after_callback"][seq1] = dict()
node["SubscriptionQueue_call_after_callback"][seq1]["time"] = time
elif f_type == "TransportTCP_write":
node["TransportTCP_write"][seq1] = dict()
node["TransportTCP_write"][seq1]["time"] = time
elif f_type == "TransportTCP_read":
sock = seq1
seq = seq2
if not seq in node["TransportTCP_read"].keys():
node["TransportTCP_read"][seq] = dict()
node["TransportTCP_read"][seq][sock] = dict()
node["TransportTCP_read"][seq][sock]["time"] = time
elif f_type == "accept":
if not seq2 in node["socket"].keys():
node["socket"][seq2] = dict()
node["socket"][seq2]["to"] = seq1
elif f_type == "connect":
if not seq2 in node["socket"].keys():
node["socket"][seq2] = dict()
node["socket"][seq2]["to"] = seq1
elif f_type == "bind":
if not seq2 in node["socket"].keys():
node["socket"][seq2] = dict()
node["socket"][seq2]["from"] = seq1
node["port"].append(seq1)
else:
print("Error")
return node
def calc_e2e_intra(node,option):
lat = dict()
for seq, t in node["SubscriptionQueue_push"].items():
time1 = t["time"]
seq_p = t["seq"]
try:
time2 = node["SubscriptionQueue_call_before_callback"][seq_p]["time"]
name = node["SubscriptionQueue_call_before_callback"][seq_p]["name"]
except:
continue
if seq in node["TransportTCP_read"].keys():
continue
if not name in lat.keys():
lat[name] = dict()
lat[name]["sub queue"] = list()
lat[name]["sub queue"].append(time2 - time1)
return lat
def calc_e2e_inter(node1,node2, option):
lat = dict()
timeline = dict()
for seq, t in node1["Publisher_publish"].items():
time0 = t["time"]
try:
time1 = node1["Publication_publish"][seq]["time"]
except:
continue
try:
time2 = node1["Publication_enqueueMessage"][seq]["time"] # time2-1: pub_queue
seq_e = node1["Publication_enqueueMessage"][seq]["seq"] # time2-1: pub_queue
time3 = node1["TransportTCP_write"][seq_e]["time"]
except:
continue
try:
node2["TransportTCP_read"][seq_e]
except:
continue
time4 = 0
for sock, t in node2["TransportTCP_read"][seq_e].items():
try:
if node2["socket"][sock]["to"] in node1["port"]:
time4 = t["time"]
pass
except:
continue
if time4 - time3 < 0:
continue
try:
time5 = node2["SubscriptionQueue_push"][seq_e]["time"]
seq_p = node2["SubscriptionQueue_push"][seq_e]["seq"]
time6 = node2["SubscriptionQueue_call_before_callback"][seq_p]["time"]
name = node2["SubscriptionQueue_call_before_callback"][seq_p]["name"]
except:
continue
if not name in lat.keys():
lat[name] = dict()
lat[name]["pub queue"] = list()
lat[name]["kernel"] = list()
lat[name]["sub queue"] = list()
timeline[name] = dict()
timeline[name]["pub queue"] = list()
timeline[name]["kernel"] = list()
timeline[name]["sub queue"] = list()
if not hasattr(option,"ros_detail") or not option.ros_detail:
lat[name]["ROS"] = list()
else:
lat[name]["ROS: app - pub queue"] = list()
lat[name]["ROS: pub queue - send"] = list()
lat[name]["ROS: recv - sub queue"] = list()
timeline[name]["ROS: app - pub queue"] = list()
timeline[name]["ROS: pub queue - send"] = list()
timeline[name]["ROS: recv - sub queue"] = list()
lat[name]["pub queue"].append(time2 - time1)
lat[name]["kernel"].append(time4 - time3)
lat[name]["sub queue"].append(time6 - time5)
timeline[name]["pub queue"].append(time1)
timeline[name]["kernel"].append(time3)
timeline[name]["sub queue"].append(time5)
if not hasattr(option,"ros_detail") or not option.ros_detail:
lat[name]["ROS"].append(time6 - time0 - (time6 - time5) - (time4 - time3) - (time2 - time1))
else:
lat[name]["ROS: app - pub queue"].append(time1 - time0)
lat[name]["ROS: pub queue - send"].append(time3 - time2)
lat[name]["ROS: recv - sub queue"].append(time5 - time4)
timeline[name]["ROS: app - pub queue"].append(time0)
timeline[name]["ROS: pub queue - send"].append(time2)
timeline[name]["ROS: recv - sub queue"].append(time4)
return lat,timeline
def show_inter(args):
n1 = collect(args.src_node)
n2 = collect(args.dst_node)
lat,timeline = calc_e2e_inter(n1,n2, args)
node_num = len(lat)
if node_num == 0:
print("None")
sys.exit(0)
time_num = len(list(lat.values())[0])
if args.concat:
fig, ax = plt.subplots(node_num, time_num, sharex="row", sharey="row",squeeze=False)
else:
fig, ax = plt.subplots(node_num, 1, sharex="row", sharey="row",squeeze=False)
for i,(node_name, node_time) in enumerate(lat.items(), start=0):
assert reduce(lambda x,y: x if len(x) == len(y) else False, node_time.values())
try:
demangler_out = subprocess.run(["./demangler", node_name], capture_output=True)
node_name = demangler_out.stdout.decode('utf-8')
except:
print("error: demangler")
print()
print(node_name)
print("num: ", len(list(node_time.values())[0]))
for j,(lat_name, time) in enumerate(node_time.items()):
if args.concat:
ax[i,j].hist(time, bins =50, histtype = 'bar')
ax[i,j].set_title(lat_name)
else:
ax[i,0].hist(time, bins =50, histtype = 'bar', label = lat_name)
ax[i,0].legend(loc="best")
plt.show()
def show_intra(args):
n = collect(args.node)
lat = calc_e2e_intra(n,args)
fig = plt.figure()
node_num = len(lat)
if node_num == 0:
print("None")
sys.exit(0)
for i,(node_name, node_time) in enumerate(lat.items(), start=0):
assert reduce(lambda x,y: x if len(x) == len(y) else False, node_time.values())
try:
demangler_out = subprocess.run(["./demangler", node_name], capture_output=True)
node_name = demangler_out.stdout.decode('utf-8')
except:
print("error: demangler")
print()
print(node_name)
print("num: ", len(list(node_time.values())[0]))
time_num = len(node_time)
for j,(lat_name, time) in enumerate(node_time.items(), start=1):
if args.concat:
ax = fig.add_subplot(node_num, time_num, time_num*i+j)
else:
ax = fig.add_subplot(node_num,1,1)
ax.hist(time, bins =50, histtype = 'bar', label = lat_name)
ax.legend(loc="best")
plt.show()
def show_stack(args):
latencies = list()
lat_source = list()
index = list()
for nodes in args.nodes:
n1 = collect(nodes[0])
n2 = collect(nodes[1])
lat,timeline = calc_e2e_inter(n1,n2,args)
index.append(nodes[2])
node_num = len(lat)
if node_num != 1:
print("Error: the number of topic must be 1. ",nodes[2])
sys.exit(0)
for i,(node_name, node_time) in enumerate(lat.items(), start=0):
assert reduce(lambda x,y: x if len(x) == len(y) else False, node_time.values())
try:
demangler_out = subprocess.run(["./demangler", node_name], capture_output=True)
node_name = demangler_out.stdout.decode('utf-8')
except:
print("error: demangler")
print()
print(node_name)
print("num: ", len(list(node_time.values())[0]))
lat = list()
lat_source = list()
for j,(lat_name, time) in enumerate(node_time.items(), start=1):
if args.kind == "mean":
lat.append(mean(time))
elif args.kind == "median":
lat.append(median_grouped(time))
elif args.kind == "tail":
lat.append(max(time))
elif args.kind == "stdev":
lat.append(stdev(time))
elif args.kind == "99percentile":
lat.append(np.percentile(time,99))
lat_source.append(lat_name)
latencies.append(lat)
fig, ax = plt.subplots()
data = pd.DataFrame(latencies, index=index, columns=lat_source)
data.plot(kind='bar', stacked=True, ax=ax)
plt.show()
def show_timeline(args):
n1 = collect(args.src_node)
n2 = collect(args.dst_node)
if args.pickup == None:
print("Please select: kernel, pubq, subq, ros")
sys.exit(0)
pickup_num = len(args.pickup)
lat, timeline = calc_e2e_inter(n1,n2, args)
node_num = len(lat)
if node_num == 0:
print("None")
sys.exit(0)
time_num = len(list(lat.values())[0])
fig, ax = plt.subplots(node_num, pickup_num, sharex="row", sharey="row",squeeze=False)
for i,(node_name, node_time) in enumerate(lat.items(), start=0):
assert reduce(lambda x,y: x if len(x) == len(y) else False, node_time.values())
try:
demangler_out = subprocess.run(["./demangler", node_name], capture_output=True)
node_name_demangle = demangler_out.stdout.decode('utf-8')
except:
print("error: demangler")
node_name_demangle = ""
print()
print(node_name, " (", node_name_demangle, ")")
print("num: ", len(list(node_time.values())[0]))
for j,key in enumerate(args.pickup):
ax[i,j].plot(timeline[node_name][key], lat[node_name][key])
ax[i,j].set_title(key)
plt.show()
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
parser_inter = subparsers.add_parser('inter')
parser_inter.add_argument("src_node", metavar="<src node>")
parser_inter.add_argument("dst_node", metavar="<dst node>")
parser_inter.add_argument("--ros-detail", dest="ros_detail", action='store_true')
parser_inter.add_argument("-c", dest="concat", action='store_true')
parser_inter.set_defaults(handler=show_inter)
parser_intra = subparsers.add_parser('intra')
parser_intra.add_argument("node", metavar="<node>")
parser_intra.add_argument("--ros-detail", dest="ros_detail", action='store_true')
parser_intra.add_argument("-c", dest="concat", action='store_true')
parser_intra.set_defaults(handler=show_intra)
parser_stack = subparsers.add_parser('stack')
parser_stack.add_argument("--nodes", "-n", metavar=("src","dst","name"), nargs=3, action="append", required=True)
parser_stack.add_argument("--ros-detail", dest="ros_detail", action='store_true')
parser_stack.add_argument("--kind","-k", choices=["median","mean","tail","stdev","99percentile"], default = "mean")
parser_stack.set_defaults(handler=show_stack)
parser_timeline = subparsers.add_parser('timeline')
parser_timeline.add_argument("src_node", metavar="<src node>")
parser_timeline.add_argument("dst_node", metavar="<dst node>")
parser_timeline.add_argument('--kernel', dest='pickup', action='append_const', const="kernel")
parser_timeline.add_argument('--pubq', dest='pickup', action='append_const', const="pub queue")
parser_timeline.add_argument('--subq', dest='pickup', action='append_const', const="sub queue")
parser_timeline.set_defaults(handler=show_timeline)
args = parser.parse_args()
if hasattr(args, 'handler'):
args.handler(args)
else:
print("Command line parse error")
|
{"hexsha": "4f1eab1c3cc220b768892c9f8150bd1767358d7c", "size": 15604, "ext": "py", "lang": "Python", "max_stars_repo_path": "calc_e2e.py", "max_stars_repo_name": "mu-mu-mu/ros1_analysis", "max_stars_repo_head_hexsha": "48f69e337cee9a992904fa6b5394251f8876cdc0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "calc_e2e.py", "max_issues_repo_name": "mu-mu-mu/ros1_analysis", "max_issues_repo_head_hexsha": "48f69e337cee9a992904fa6b5394251f8876cdc0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "calc_e2e.py", "max_forks_repo_name": "mu-mu-mu/ros1_analysis", "max_forks_repo_head_hexsha": "48f69e337cee9a992904fa6b5394251f8876cdc0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1441441441, "max_line_length": 115, "alphanum_fraction": 0.5817739041, "include": true, "reason": "import numpy,from scipy", "num_tokens": 3681}
|
C
C $Id: kurv1.f,v 1.5 2008-07-27 03:10:11 haley Exp $
C
C Copyright (C) 2000
C University Corporation for Atmospheric Research
C All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
C NOTE: If you make any changes to this software, please remember to
C make the same changes to the corresponding double precision routine.
C
subroutine kurv1 (n,x,y,slp1,slpn,islpsw,xp,yp,temp,s,
* sigma,ierr)
c
integer n,islpsw,ierr
real x(n),y(n),slp1,slpn,xp(n),yp(n),temp(n),s(n),
* sigma
c
c coded by alan kaylor cline
c from fitpack -- january 26, 1987
c a curve and surface fitting package
c a product of pleasant valley software
c 8603 altus cove, austin, texas 78759, usa
c
c this subroutine determines the parameters necessary to
c compute a spline under tension forming a curve in the
c plane and passing through a sequence of pairs (x(1),y(1)),
c ...,(x(n),y(n)). for actual computation of points on the
c curve it is necessary to call the subroutine kurv2.
c
c on input--
c
c n is the number of points to be interpolated (n.ge.2).
c
c x is an array containing the n x-coordinates of the
c points.
c
c y is an array containing the n y-coordinates of the
c points. (adjacent x-y pairs must be distinct, i. e.
c either x(i) .ne. x(i+1) or y(i) .ne. y(i+1), for
c i = 1,...,n-1.)
c
c slp1 and slpn contain the desired values for the angles
c (in radians) of the slope at (x(1),y(1)) and (x(n),y(n))
c respectively. the angles are measured counter-clock-
c wise from the x-axis and the positive sense of the curve
c is assumed to be that moving from point 1 to point n.
c the user may omit values for either or both of these
c parameters and signal this with islpsw.
c
c islpsw contains a switch indicating which slope data
c should be used and which should be estimated by this
c subroutine,
c = 0 if slp1 and slpn are to be used,
c = 1 if slp1 is to be used but not slpn,
c = 2 if slpn is to be used but not slp1,
c = 3 if both slp1 and slpn are to be estimated
c internally.
c
c xp and yp are arrays of length at least n.
c
c temp is an array of length at least n which is used
c for scratch storage.
c
c s is an array of length at least n.
c
c and
c
c sigma contains the tension factor. this value indicates
c the curviness desired. if abs(sigma) is nearly zero
c (e.g. .001) the resulting curve is approximately a cubic
c spline. if abs(sigma) is large (e. g. 50.) the resulting
c curve is nearly a polygonal line. if sigma equals zero a
c cubic spline results. a standard value for sigma is
c approximately 1. in absolute value.
c
c on output--
c
c xp and yp contain information about the curvature of the
c curve at the given nodes.
c
c s contains the polygonal arclengths of the curve.
c
c ierr contains an error flag,
c = 0 for normal return,
c = 1 if n is less than 2,
c = 2 if adjacent coordinate pairs coincide.
c
c and
c
c n, x, y, slp1, slpn, islpsw, and sigma are unaltered.
c
c this subroutine references package modules ceez, terms,
c and snhcsh.
c
c-----------------------------------------------------------
c
nm1 = n-1
np1 = n+1
ierr = 0
if (n .le. 1) go to 11
c
c determine polygonal arclengths
c
s(1) = 0.
do 1 i = 2,n
im1 = i-1
1 s(i) = s(im1)+sqrt((x(i)-x(im1))**2+
* (y(i)-y(im1))**2)
c
c denormalize tension factor
c
sigmap = abs(sigma)*float(n-1)/s(n)
c
c approximate end slopes
c
if (islpsw .ge. 2) go to 2
slpp1x = cos(slp1)
slpp1y = sin(slp1)
go to 4
2 dels1 = s(2)-s(1)
dels2 = dels1+dels1
if (n .gt. 2) dels2 = s(3)-s(1)
if (dels1 .eq. 0. .or. dels2 .eq. 0.) go to 12
call ceez (dels1,dels2,sigmap,c1,c2,c3,n)
sx = c1*x(1)+c2*x(2)
sy = c1*y(1)+c2*y(2)
if (n .eq. 2) go to 3
sx = sx+c3*x(3)
sy = sy+c3*y(3)
3 delt = sqrt(sx*sx+sy*sy)
slpp1x = sx/delt
slpp1y = sy/delt
4 if (islpsw .eq. 1 .or. islpsw .eq. 3) go to 5
slppnx = cos(slpn)
slppny = sin(slpn)
go to 7
5 delsn = s(n)-s(nm1)
delsnm = delsn+delsn
if (n .gt. 2) delsnm = s(n)-s(n-2)
if (delsn .eq. 0. .or. delsnm .eq. 0.) go to 12
call ceez (-delsn,-delsnm,sigmap,c1,c2,c3,n)
sx = c1*x(n)+c2*x(nm1)
sy = c1*y(n)+c2*y(nm1)
if (n .eq. 2) go to 6
sx = sx+c3*x(n-2)
sy = sy+c3*y(n-2)
6 delt = sqrt(sx*sx+sy*sy)
slppnx = sx/delt
slppny = sy/delt
c
c set up right hand sides and tridiagonal system for xp and
c yp and perform forward elimination
c
7 dx1 = (x(2)-x(1))/s(2)
dy1 = (y(2)-y(1))/s(2)
call terms (diag1,sdiag1,sigmap,s(2))
xp(1) = (dx1-slpp1x)/diag1
yp(1) = (dy1-slpp1y)/diag1
temp(1) = sdiag1/diag1
if (n .eq. 2) go to 9
do 8 i = 2,nm1
dels2 = s(i+1)-s(i)
if (dels2 .eq. 0.) go to 12
dx2 = (x(i+1)-x(i))/dels2
dy2 = (y(i+1)-y(i))/dels2
call terms (diag2,sdiag2,sigmap,dels2)
diag = diag1+diag2-sdiag1*temp(i-1)
diagin = 1./diag
xp(i) = (dx2-dx1-sdiag1*xp(i-1))*diagin
yp(i) = (dy2-dy1-sdiag1*yp(i-1))*diagin
temp(i) = sdiag2*diagin
dx1 = dx2
dy1 = dy2
diag1 = diag2
8 sdiag1 = sdiag2
9 diag = diag1-sdiag1*temp(nm1)
xp(n) = (slppnx-dx1-sdiag1*xp(nm1))/diag
yp(n) = (slppny-dy1-sdiag1*yp(nm1))/diag
c
c perform back substitution
c
do 10 i = 2,n
ibak = np1-i
xp(ibak) = xp(ibak)-temp(ibak)*xp(ibak+1)
10 yp(ibak) = yp(ibak)-temp(ibak)*yp(ibak+1)
return
c
c too few points
c
11 ierr = 1
return
c
c coincident adjacent points
c
12 ierr = 2
return
end
|
{"hexsha": "c659c950ded7fa10e14c12ee73761e15a77d20c5", "size": 6071, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "ngmath/src/lib/gridpack/fitgrid/kurv1.f", "max_stars_repo_name": "tenomoto/ncl", "max_stars_repo_head_hexsha": "a87114a689a1566e9aa03d85bcf6dc7325b47633", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 210, "max_stars_repo_stars_event_min_datetime": "2016-11-24T09:05:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T19:15:32.000Z", "max_issues_repo_path": "ngmath/src/lib/gridpack/fitgrid/kurv1.f", "max_issues_repo_name": "tenomoto/ncl", "max_issues_repo_head_hexsha": "a87114a689a1566e9aa03d85bcf6dc7325b47633", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 156, "max_issues_repo_issues_event_min_datetime": "2017-09-22T09:56:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:02:21.000Z", "max_forks_repo_path": "ngmath/src/lib/gridpack/fitgrid/kurv1.f", "max_forks_repo_name": "tenomoto/ncl", "max_forks_repo_head_hexsha": "a87114a689a1566e9aa03d85bcf6dc7325b47633", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 58, "max_forks_repo_forks_event_min_datetime": "2016-12-14T00:15:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T09:13:00.000Z", "avg_line_length": 30.355, "max_line_length": 71, "alphanum_fraction": 0.5852413112, "num_tokens": 2155}
|
import numpy as np
import fabio
import configparser
from fabio.edfimage import edfimage
from fabio.tifimage import tifimage
### This function save the calibrant image as edf extension ###
### root_save: path of the folder where the image will be saved
### save_img_name: name of the image
### extension: format (extension) of the image (edf, tif, ...)
### img_matrix: the matrix to be saved as image
def save_edf_image(root_save, save_img_name, extension, img_matrix):
iheader = {}
edfimg = edfimage(data=img_matrix, header=iheader)
edfimg.write(root_save + "/" + save_img_name + "." + extension)
return
|
{"hexsha": "477ecb619cb11c6c1f784ced6d35c64a291e4375", "size": 637, "ext": "py", "lang": "Python", "max_stars_repo_path": "easistrain/func_save_edf_image.py", "max_stars_repo_name": "woutdenolf/easistrain", "max_stars_repo_head_hexsha": "0484168e33e548af01a5cc649abf815c45b182f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "easistrain/func_save_edf_image.py", "max_issues_repo_name": "woutdenolf/easistrain", "max_issues_repo_head_hexsha": "0484168e33e548af01a5cc649abf815c45b182f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2021-11-10T08:36:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T08:31:17.000Z", "max_forks_repo_path": "easistrain/func_save_edf_image.py", "max_forks_repo_name": "EASI-STRESS/easistrain", "max_forks_repo_head_hexsha": "86192d1c4135875daec8e4e4abcb67e372f86efb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-04T14:02:16.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-04T14:02:16.000Z", "avg_line_length": 37.4705882353, "max_line_length": 69, "alphanum_fraction": 0.7174254317, "include": true, "reason": "import numpy", "num_tokens": 163}
|
import torch
import os
import gc
import pandas as pd
import numpy as np
from BengaliDataset import BengaliDataset
from Resnet import ResNet
from Utils import seed_everything
# Constants
# Setting
SEED = 222
BATCH_SIZE = 64
HEIGHT = 137
WIDTH = 236
device = "cuda" if torch.cuda.is_available() else "cpu"
seed_everything(SEED)
# Create Model
model = ResNet().to(device)
model_path = '../input/resnet18/resnet_saved_weights.pth'
# load model from dict to create test output csv
model.load_state_dict(torch.load(model_path))
# Get Parquet files for Testing
data_dir = '../input/bengaliai-cv19'
files_test = [f'test_image_data_{fid}.parquet' for fid in range(4)]
# Predict Test values
model.eval()
row_id = []
target = []
for fname in files_test:
# Read in the data files
file = os.path.join(data_dir, fname)
print(F"File name is {file}")
df_test = pd.read_parquet(file)
print(F"Shape of this parquet dataframe is: {df_test.shape}")
df_test.set_index('image_id', inplace=True)
test_image = BengaliDataset(df_test, img_height=HEIGHT,
img_width=WIDTH)
test_loader = torch.utils.data.DataLoader(dataset=test_image,
batch_size=BATCH_SIZE,
num_workers=4,
shuffle=False)
with torch.no_grad():
for idx, (img_ids, img) in enumerate(test_loader):
img = img.to(device)
pred_graphemes, pred_vowels, pred_consonants = model(img)
for img_id, pred_grapheme, pred_vowel, pred_consonant in zip(
img_ids, pred_graphemes, pred_vowels,
pred_consonants):
row_id.append(img_id + '_consonant_diacritic')
target.append(
pred_consonant.argmax(0).cpu().detach().numpy())
row_id.append(img_id + '_grapheme_root')
target.append(
pred_grapheme.argmax(0).cpu().detach().numpy())
row_id.append(img_id + '_vowel_diacritic')
target.append(
pred_vowel.argmax(0).cpu().detach().numpy())
del (df_test, test_image, test_loader)
gc.collect()
# Create csv file to submit to competition
df_submission = pd.DataFrame(
{
'row_id': row_id,
'target': np.array(target)
},
columns=['row_id', 'target']
)
df_submission.to_csv('submission.csv', index=False)
df_submission.head(10)
|
{"hexsha": "21928405de2a90801cea41fca354009a06452e87", "size": 2525, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/CreateTestCsv.py", "max_stars_repo_name": "jaswged/bengali-handwritten-ai", "max_stars_repo_head_hexsha": "aef86c495255cf9ec671f46f1c919a7f97d35762", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/CreateTestCsv.py", "max_issues_repo_name": "jaswged/bengali-handwritten-ai", "max_issues_repo_head_hexsha": "aef86c495255cf9ec671f46f1c919a7f97d35762", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CreateTestCsv.py", "max_forks_repo_name": "jaswged/bengali-handwritten-ai", "max_forks_repo_head_hexsha": "aef86c495255cf9ec671f46f1c919a7f97d35762", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.421686747, "max_line_length": 73, "alphanum_fraction": 0.6194059406, "include": true, "reason": "import numpy", "num_tokens": 580}
|
import numpy as np
import scipy.sparse as sp
from ...common_files.common_infos import CommonInfos
import multiprocessing as mp
from ...solvers.solvers_scipy.solver_sp import SolverSp
from ...solvers.solvers_trilinos.solvers_tril import solverTril
import time
class masterNeumanNonNested:
def __init__(self, data_impress, elements_lv0, ml_data, n_levels, T_without, wells, pare=False):
self.data_impress = data_impress
self.elements_lv0 = elements_lv0
self.ml_data = ml_data
self.n_levels = n_levels
self.T_without = T_without
self.wells = wells
self.pare = pare
self.one_worker = True
def get_n_workers(self, list_of_subdomains):
if self.one_worker:
n_cpu = 1
else:
n_cpu = mp.cpu_count()//2 - 1
self.n_workers = n_cpu
list_of_process_per_cpu = []
n_subdomains = len(list_of_subdomains)
resto = n_subdomains % self.n_workers
n_process_per_cpu = n_subdomains//self.n_workers
if n_process_per_cpu > 0:
for i in range(self.n_workers):
list_of_process_per_cpu.append(list_of_subdomains[i*n_process_per_cpu:n_process_per_cpu*(i+1)])
if resto != 0:
for i in range(resto):
list_of_process_per_cpu[i].append(list_of_subdomains[-i])
else:
self.n_workers = resto
for i in range(resto):
list_of_process_per_cpu[i].append(list_of_subdomains[-i])
return list_of_process_per_cpu
def get_subdomains(self):
'''
ordem de envio:
volumes: global id dos volumes locais
ind_diric: indice dos volumes com pressao prescrita
ind_neum: indice dos volumes com vazao prescrita
val_diric: valores de pressao prescrita
val_neum: valores de vazao prescrita
local_transm: transmissibilidade local
all_faces: todas faces do coarse volume
intern_faces: faces internas do coarse volume
intersect_faces: faces na interseccao
'''
list_of_subdomains = []
pms_flux_faces = np.zeros(len(self.elements_lv0['faces']))
levels = self.data_impress['LEVEL']
pms = self.data_impress['pms']
remaped_internal_faces = self.elements_lv0['remaped_internal_faces']
neig_internal_faces = self.elements_lv0['neig_internal_faces']
gid0 = self.data_impress['GID_0']
n_volumes = len(levels)
if self.pare:
import pdb; pdb.set_trace()
self.data_impress['val_diric'][:]=0
self.data_impress['val_neum'][:]=0
for level in range(1, self.n_levels):
str_level = str(level)
set_level = set([level])
all_gids_coarse = self.data_impress['GID_'+ str_level]
# all_local_ids_coarse = self.data_impress['COARSE_LOCAL_ID_'+ str_level]
all_intern_boundary_volumes = self.ml_data['internal_boundary_fine_volumes_level_'+ str_level]
all_intersect_faces = self.ml_data['coarse_intersect_faces_level_'+ str_level]
all_intern_faces = self.ml_data['coarse_internal_faces_level_'+ str_level]
all_faces = self.ml_data['coarse_faces_level_'+ str_level]
all_fine_vertex = self.ml_data['fine_vertex_coarse_volumes_level_'+ str_level]
coarse_ids = self.ml_data['coarse_primal_id_level_'+ str_level]
gids_level = np.unique(all_gids_coarse)
for gidc in gids_level:
intersect_faces = all_intersect_faces[coarse_ids==gidc][0] # faces na interseccao
intern_local_faces = all_intern_faces[coarse_ids==gidc][0] # faces internas
faces = all_faces[coarse_ids==gidc][0] # faces do volume
intern_boundary_volumes = all_intern_boundary_volumes[coarse_ids==gidc][0] # volumes internos no contorno
vertex = all_fine_vertex[coarse_ids==gidc]
pressure_vertex = pms[vertex]
volumes = self.elements_lv0['volumes'][all_gids_coarse==gidc]
level_volumes = levels[volumes]
volumes_dirichlet = set(volumes) & set(self.wells['ws_p'])
volumes_neuman = set(volumes) & set(self.wells['ws_q'])
adjs_intersect_faces = neig_internal_faces[remaped_internal_faces[intersect_faces]]
adj_intern_local_faces = neig_internal_faces[remaped_internal_faces[intern_local_faces]]
v0_new = adjs_intersect_faces.copy()
intersect_faces_new = intersect_faces.copy()
intern_boundary_volumes_new = intern_boundary_volumes.copy()
ind_diric = []
ind_neum = []
val_diric = []
val_neum = []
if volumes_dirichlet:
ind_diric += list(volumes_dirichlet)
for v in ind_diric:
val_diric += [self.wells['values_p'][self.wells['ws_p']==v][0]]
inds = ~((v0_new[:,0]==v) | (v0_new[:,1]==v))
intersect_faces_new = intersect_faces_new[inds]
intern_boundary_volumes_new = intern_boundary_volumes_new[~(intern_boundary_volumes_new==v)]
if volumes_neuman:
ind_neum += list(volumes_neuman)
for v in ind_neum:
val_neum += [self.wells['values_q'][self.wells['ws_q']==v][0]]
inds = ~((v0_new[:,0]==v) | (v0_new[:,1]==v))
v0_new = v0_new[inds]
intersect_faces_new = intersect_faces_new[inds]
intern_boundary_volumes_new = intern_boundary_volumes_new[~(intern_boundary_volumes_new==v)]
if len(intern_boundary_volumes_new) > 0:
v0 = v0_new
pms0 = pms[v0[:,0]]
pms1 = pms[v0[:,1]]
t0 = self.data_impress['transmissibility'][intersect_faces_new]
pms_flux_faces_local = get_flux_faces(pms1, pms0, t0)
pms_flux_faces[intersect_faces] = pms_flux_faces_local
lines = np.concatenate([v0[:, 0], v0[:, 1]])
cols = np.repeat(0, len(lines))
data = np.concatenate([pms_flux_faces_local, -pms_flux_faces_local])
flux_pms_volumes = sp.csc_matrix((data, (lines, cols)), shape=(n_volumes, 1)).toarray().flatten()
presc_flux_intern_boundary_volumes = flux_pms_volumes[intern_boundary_volumes_new]
ind_neum += list(intern_boundary_volumes_new)
val_neum += list(presc_flux_intern_boundary_volumes)
if len(ind_diric) == 0:
if set(vertex) & set(ind_neum):
candidatos = set(volumes) - set(ind_neum)
vol = candidatos.pop()
ind_diric += [vol]
val_diric += [pms[vol]]
else:
ind_diric += list(vertex)
val_diric += list(pressure_vertex)
# ind_diric=volumes[level_volumes==1]
# if len(ind_diric)>0:
#
# ind_diric=np.setdiff1d(ind_diric,intern_boundary_volumes_new)
# if len(ind_diric)>0:
# ind_diric=ind_diric[0]
# else:
# ind_diric=vertex
# else:
# ind_diric=vertex
# val_diric=pms[ind_diric]
self.data_impress['val_diric'][ind_diric]=val_diric
self.data_impress['val_neum'][ind_neum]=val_neum
list_of_subdomains.append(Subdomain(volumes, ind_diric, ind_neum, val_diric, val_neum, intern_local_faces, adj_intern_local_faces, self.T_without))
return list_of_subdomains, pms_flux_faces
def get_subdomains_2(self):
'''
ordem de envio:
volumes: global id dos volumes locais
ind_diric: indice dos volumes com pressao prescrita
ind_neum: indice dos volumes com vazao prescrita
val_diric: valores de pressao prescrita
val_neum: valores de vazao prescrita
local_transm: transmissibilidade local
all_faces: todas faces do coarse volume
intern_faces: faces internas do coarse volume
intersect_faces: faces na interseccao
'''
list_of_subdomains = []
pms_flux_faces = np.zeros(len(self.elements_lv0['faces']))
levels = self.data_impress['LEVEL']
pms = self.data_impress['pms']
remaped_internal_faces = self.elements_lv0['remaped_internal_faces']
neig_internal_faces = self.elements_lv0['neig_internal_faces']
gid0 = self.data_impress['GID_0']
n_volumes = len(gid0)
for level in range(1, self.n_levels):
str_level = str(level)
set_level = set([level])
all_gids_coarse = self.data_impress['GID_'+ str_level]
all_intern_boundary_volumes = self.ml_data['internal_boundary_fine_volumes_level_'+ str_level]
all_intersect_faces = self.ml_data['coarse_intersect_faces_level_'+ str_level]
all_intern_faces = self.ml_data['coarse_internal_faces_level_'+ str_level]
all_faces = self.ml_data['coarse_faces_level_'+ str_level]
all_fine_vertex = self.ml_data['fine_vertex_coarse_volumes_level_'+ str_level]
coarse_ids = self.ml_data['coarse_primal_id_level_'+ str_level]
gids_level = np.unique(all_gids_coarse)
import pdb; pdb.set_trace()
def preprocess(self):
list_of_subdomains, self.global_ms_flux_faces = self.get_subdomains()
list_of_process_per_cpu = self.get_n_workers(list_of_subdomains)
return list_of_process_per_cpu
def run(self):
list_of_process_per_cpu = self.preprocess()
master2worker = [mp.Pipe() for _ in range(self.n_workers)]
m2w, w2m = list(zip(*master2worker))
procs = [mp.Process(target=run_thing, args=[LocalSolution(obj, comm)]) for obj, comm in zip(list_of_process_per_cpu, w2m)]
del list_of_process_per_cpu
global_pcorr = np.zeros(len(self.data_impress['GID_0']))
for proc in procs:
proc.start()
for comm in m2w:
msg = comm.recv()
for resp in msg:
faces = resp[0]['faces']
ms_flux = resp[0]['ms_flux_faces']
self.global_ms_flux_faces[faces] = ms_flux
volumes = resp[1]['volumes']
pcorr = resp[1]['pcorr']
global_pcorr[volumes] = pcorr
for proc in procs:
proc.join()
return self.global_ms_flux_faces.copy(), global_pcorr
def get_flux_faces(p1, p0, t0, flux_grav_faces=None):
if flux_grav_faces != None:
flux = -((p1 - p0) * t0 - flux_grav_faces)
else:
flux = -((p1 - p0) * t0)
return flux
class Subdomain(CommonInfos):
def __init__(self, volumes, ind_diric, ind_neum, val_diric, val_neum,
intern_faces, adjs_intern_faces, T_global):
self.T_local = self.get_local_t(T_global, volumes).tolil()
self.volumes = volumes
self.ids_local = np.arange(len(volumes))
self.ind_diric = ind_diric
self.ind_neum = ind_neum
self.val_diric = val_diric
self.val_neum = val_neum
self.intern_faces = intern_faces
self.adjs_intern_faces = adjs_intern_faces
self.map_gid_in_lid = np.repeat(-1, volumes.max()+1)
self.map_gid_in_lid[volumes] = self.ids_local
class LocalSolution:
def __init__(self, subdomains, comm):
self.subdomains = subdomains
self.comm = comm
def run(self):
data = []
dt = [('faces', int), ('ms_flux_faces', float)]
dt_vol = [('volumes', int), ('pcorr', float)]
solver = solverTril()
for subd in self.subdomains:
volumes = subd.volumes
T_local = subd.T_local
ids_local = subd.ids_local
ind_diric = subd.ind_diric
ind_neum = subd.ind_neum
val_diric = subd.val_diric
val_neum = subd.val_neum
intern_faces = subd.intern_faces
adjs_intern_faces = subd.adjs_intern_faces
map_gid_in_lid = subd.map_gid_in_lid
ind_diric_local = map_gid_in_lid[ind_diric]
T_local_2 = T_local.copy()
T_local_2[ind_diric_local] = 0
T_local_2[ind_diric_local, ind_diric_local] = 1
b = np.zeros(len(volumes))
b[map_gid_in_lid[ind_neum]] = val_neum
b[map_gid_in_lid[ind_diric]] = val_diric
T_local_2 = T_local_2.tocsc()
x = solver.solve_linear_problem(T_local_2,b)
# x=a.solve(b)
# print('\n')
# print('pcorr')
# print(x)
# print('val_diric')
# print(val_diric)
# print('\n')
del T_local_2
t0 = T_local[map_gid_in_lid[adjs_intern_faces[:,0]], map_gid_in_lid[adjs_intern_faces[:,1]]].toarray().flatten()
p0 = x[map_gid_in_lid[adjs_intern_faces[:,0]]]
p1 = x[map_gid_in_lid[adjs_intern_faces[:,1]]]
ms_flux = get_flux_faces(p1, p0, t0)
sarray = np.zeros(len(intern_faces), dtype=dt)
sarray['faces'] = intern_faces
sarray['ms_flux_faces'] = ms_flux
sarray_vol = np.zeros(len(volumes), dtype=dt_vol)
sarray_vol['volumes'] = volumes
sarray_vol['pcorr'] = x
data.append([sarray, sarray_vol])
self.comm.send(data)
def run_thing(local_solution_obj):
local_solution_obj.run()
|
{"hexsha": "4493bf3c587db86f991807366822c87413283ba8", "size": 14055, "ext": "py", "lang": "Python", "max_stars_repo_path": "packs/adm/non_uniform/paralel_neuman_new0.py", "max_stars_repo_name": "CiceroAraujo/SB", "max_stars_repo_head_hexsha": "637cc4bc63c952f058c316b2b1fbfbb5cd6250c8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-09T17:42:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-09T17:42:52.000Z", "max_issues_repo_path": "packs/adm/non_uniform/paralel_neuman_new0.py", "max_issues_repo_name": "CiceroAraujo/SB", "max_issues_repo_head_hexsha": "637cc4bc63c952f058c316b2b1fbfbb5cd6250c8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packs/adm/non_uniform/paralel_neuman_new0.py", "max_forks_repo_name": "CiceroAraujo/SB", "max_forks_repo_head_hexsha": "637cc4bc63c952f058c316b2b1fbfbb5cd6250c8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.8575581395, "max_line_length": 163, "alphanum_fraction": 0.5982212736, "include": true, "reason": "import numpy,import scipy", "num_tokens": 3390}
|
[STATEMENT]
theorem mk_alt_consistency_subset: \<open>C \<subseteq> mk_alt_consistency C\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. C \<subseteq> mk_alt_consistency C
[PROOF STEP]
unfolding mk_alt_consistency_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. C \<subseteq> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> C \<Longrightarrow> x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> C \<Longrightarrow> x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
assume \<open>x \<in> C\<close>
[PROOF STATE]
proof (state)
this:
x \<in> C
goal (1 subgoal):
1. \<And>x. x \<in> C \<Longrightarrow> x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> C
[PROOF STEP]
have \<open>psubst id ` x \<in> C\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> C
goal (1 subgoal):
1. psubst id ` x \<in> C
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
psubst id ` x \<in> C
goal (1 subgoal):
1. \<And>x. x \<in> C \<Longrightarrow> x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
psubst id ` x \<in> C
[PROOF STEP]
have \<open>(\<exists>f. psubst f ` x \<in> C)\<close>
[PROOF STATE]
proof (prove)
using this:
psubst id ` x \<in> C
goal (1 subgoal):
1. \<exists>f. psubst f ` x \<in> C
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>f. psubst f ` x \<in> C
goal (1 subgoal):
1. \<And>x. x \<in> C \<Longrightarrow> x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. psubst f ` x \<in> C
[PROOF STEP]
show \<open>x \<in> {S. \<exists>f. psubst f ` S \<in> C}\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>f. psubst f ` x \<in> C
goal (1 subgoal):
1. x \<in> {S. \<exists>f. psubst f ` S \<in> C}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<in> {S. \<exists>f. psubst f ` S \<in> C}
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 980, "file": "FOL-Fitting_FOL_Fitting", "length": 14}
|
import argparse
import os
import numpy as np
from PIL import Image
from matplotlib import pyplot as plt
# --------------- Arguments ---------------
parser = argparse.ArgumentParser(description='Colorpalette')
parser.add_argument('--img', type=str, required=True)
args = parser.parse_args()
def get_dominant_colors(infile):
"Make a color palette"
DOMAIN_COLOR_NUM = 10
image = Image.open(infile)
w, h = image.size
if(w > h):
small_w = 100
small_h = (h * 100 / w)
else:
small_w = (w * 100 / h)
small_h = 100
#print(w,h,small_w,small_h)
small_image = image.resize((int(small_w), int(small_h)))
# import matplotlib.pyplot as plt
# plt.imshow(small_image)
# plt.show()
# image with only 10 dominating colors
result = small_image.convert("P", palette=Image.ADAPTIVE, colors=DOMAIN_COLOR_NUM)
# Find dominant colors
palette = result.getpalette()
color_counts = sorted(result.getcolors(), reverse=True)
colors = list()
for i in range(DOMAIN_COLOR_NUM):
palette_index = color_counts[i][1]
dominant_color = palette[palette_index * 3 : palette_index * 3 + 3]
colors.append(tuple(dominant_color))
# save colorpalette full image
os.makedirs("colorpalette", exist_ok=True)
for i in range(len(colors)):
color_img = np.zeros((h,w,3), dtype=np.uint8)
color_img[0:h, 0:w]=colors[i]
pil_color_img = Image.fromarray(color_img)
file_name = "colorpalette/" + "color_0" + str(i) + ".jpg"
pil_color_img.save(file_name)
#print(colors)
return colors
def plot_img_tile(colors):
"List images in tiles"
imgs = []
tile_w = 60
tile_h = 80
for i in range(len(colors)):
color_img = np.zeros((tile_h,tile_w,3), dtype=np.uint8)
color_img[0:tile_h, 0:tile_w]=colors[i]
imgs.append(color_img)
fig, ax = plt.subplots(2, int(len(colors)/2), figsize=(5, 5))
#fig.subplots_adjust(hspace=0, wspace=0)
for i in range(2):
for j in range(int(len(colors)/2)):
ax[i, j].xaxis.set_major_locator(plt.NullLocator())
ax[i, j].yaxis.set_major_locator(plt.NullLocator())
ax[i, j].imshow(imgs[1*i+j], cmap="bone")
#plt.show()
plt.savefig('colorpalette_tile.png')
plt.close()
return
if __name__ == '__main__':
# Make a color palette
colors = get_dominant_colors(args.img)
# List images in tiles
plot_img_tile(colors)
|
{"hexsha": "843893c11a0e2b8a707dfbaeb77ee59f82a21883", "size": 2363, "ext": "py", "lang": "Python", "max_stars_repo_path": "ColorpaletteFromImage.py", "max_stars_repo_name": "flow-dev/ColorpaletteFromImage", "max_stars_repo_head_hexsha": "5763942a7a5f6cf2d975e51a738a6e7df3c73538", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ColorpaletteFromImage.py", "max_issues_repo_name": "flow-dev/ColorpaletteFromImage", "max_issues_repo_head_hexsha": "5763942a7a5f6cf2d975e51a738a6e7df3c73538", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ColorpaletteFromImage.py", "max_forks_repo_name": "flow-dev/ColorpaletteFromImage", "max_forks_repo_head_hexsha": "5763942a7a5f6cf2d975e51a738a6e7df3c73538", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.6847826087, "max_line_length": 84, "alphanum_fraction": 0.6694879391, "include": true, "reason": "import numpy", "num_tokens": 661}
|
#!/usr/bin/env python3
"""
This python scripts visualizes and plots the 3D
voxels based on their confidence score and produces a heatmap.
"""
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
import time
import torch
def visualizeVoxels(voxelGrids, frameRate=10):
"""
Args:
voxelGrid (tensor): 4D tensor indicating (batchSize x zSize x ySize x xSize)
frameRate (float) : rate at which the plot should update (in Hz)
"""
batchSize = voxelGrids.shape[0]
print("Batch Size = ",batchSize)
# batchSize = voxelGrid.shape[0]
print("X0 = ",voxelGrids[0][2])
for i in range(0, batchSize):
# creating a dummy dataset
voxelGrid = voxelGrids[i]
xSize = int(voxelGrid[3])
ySize = int(voxelGrid[2])
zSize = int(voxelGrid[1])
# print("Size = ",int(xSize),ySize,zSize)
x = []
y = []
z = []
colo = []
for j in range (0, xSize):
for k in range (0, ySize):
for l in range (0, zSize):
if voxelGrid[0] > 0.5:
x.append(j)
y.append(k)
z.append(l)
colo.append(voxelGrid[0])
else:
continue
# creating figures
print("Creating Figures")
fig = plt.figure(figsize=(100, 100))
ax = fig.add_subplot(111, projection='3d')
# setting color bar
color_map = cm.ScalarMappable(cmap=cm.Greens_r)
color_map.set_array(colo)
# creating the heatmap
img = ax.scatter(x, y, z, marker='s',
s=200, color='green')
plt.colorbar(color_map)
# adding title and labels
ax.set_title("3D Heatmap")
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')
ax.set_zlabel('Z-axis')
plt.show(block=False)
plt.pause(1/frameRate)
import time
time.sleep(2)
plt.close()
|
{"hexsha": "c432df790ebd4bac4da093ac02ceaeb3645102cc", "size": 2182, "ext": "py", "lang": "Python", "max_stars_repo_path": "tools/plotvoxel.py", "max_stars_repo_name": "prithusuresh/semantic-point-generation", "max_stars_repo_head_hexsha": "e9dd107b86e6068bd1de38b6dc177108a54deee1", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-23T12:36:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-23T12:36:32.000Z", "max_issues_repo_path": "tools/plotvoxel.py", "max_issues_repo_name": "prithusuresh/semantic-point-generation", "max_issues_repo_head_hexsha": "e9dd107b86e6068bd1de38b6dc177108a54deee1", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-02-23T12:20:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-23T12:41:40.000Z", "max_forks_repo_path": "tools/plotvoxel.py", "max_forks_repo_name": "prithusuresh/semantic-point-generation", "max_forks_repo_head_hexsha": "e9dd107b86e6068bd1de38b6dc177108a54deee1", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.7105263158, "max_line_length": 84, "alphanum_fraction": 0.5174152154, "include": true, "reason": "import numpy", "num_tokens": 538}
|
library(rhdf5)
library(qvalue)
library(dplyr)
##Settings
baseFolder <- "C:/OnlineFolders/BitSync/Current_Work/EBI_HipSci/T/"
#################
##Read files.
setwd(baseFolder)
observedFeatures <- 0
results <- NULL
snpAnnotation <- NULL
featureAnnotation <- NULL
filesToRead <- list.files(".",pattern = ".h5",full.names = T)
for(i in filesToRead){
tmp=h5dump(file = i)
if(length(tmp)>0){
for (j in names(tmp)) tmp[[j]][["feature"]] <- j
observedFeatures = observedFeatures+length(tmp)
df <- bind_rows(tmp)
if(nrow(df)>0){
results = rbind(results,df)
}
}
}
rm(df,tmp)
results["QTL"] <- paste(results$snp_id, results$feature,sep="-")
if(length(which(duplicated(results$QTL)))>0){
results <- results[-which(duplicated(results$QTL)),]
}
write.table(paste(baseFolder,"permutationInformation.txt",sep=""),x = results,sep="\t",row.names=F,quote=F)
|
{"hexsha": "9a40818524c8bf9e23bd58f148d88e66af3c7dd3", "size": 911, "ext": "r", "lang": "R", "max_stars_repo_path": "Limix_QTL/post_processing/scripts/R/GettingPermQTLsFromH5.r", "max_stars_repo_name": "Bonder-MJ/limix_qtl", "max_stars_repo_head_hexsha": "71f18f4e39cdba0f0e6dc59713b83701599bc86f", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2020-05-17T18:36:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-01T11:24:24.000Z", "max_issues_repo_path": "Limix_QTL/post_processing/scripts/R/GettingPermQTLsFromH5.r", "max_issues_repo_name": "Bonder-MJ/limix_qtl", "max_issues_repo_head_hexsha": "71f18f4e39cdba0f0e6dc59713b83701599bc86f", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-04-27T19:15:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-13T09:51:27.000Z", "max_forks_repo_path": "Limix_QTL/post_processing/scripts/R/GettingPermQTLsFromH5.r", "max_forks_repo_name": "Bonder-MJ/limix_qtl", "max_forks_repo_head_hexsha": "71f18f4e39cdba0f0e6dc59713b83701599bc86f", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2019-12-04T09:57:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:20:10.000Z", "avg_line_length": 26.0285714286, "max_line_length": 108, "alphanum_fraction": 0.6443468716, "num_tokens": 253}
|
import cv2
import numpy as np
from lib.dataset import resize
def find_circle(image, kernel=33):
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image_gray = resize(image, 512, size_is_min=True)
image_gray = cv2.medianBlur(image_gray, kernel)
height, width = image_gray.shape
min_dim = min(height, width)
ratio = min_dim / 512
circles = cv2.HoughCircles(image_gray,
cv2.HOUGH_GRADIENT,
1,
20,
param1=50,
param2=30,
minRadius=min_dim // 4,
maxRadius=0)
if circles is None:
return None
circles = np.around(circles)
# get coordinates and radius of first circle
# x - horizontal dimension, left to right
# y - vertical dimension, top to bottom
x, y, r = int(circles[0, 0, 0]), int(circles[0, 0, 1]), int(circles[0, 0, 2])
# print(x, y, r)
return int(x * ratio), int(y * ratio), int(r * ratio)
def crop_by_threshold(img, threshold=7):
init_h, init_w = img.shape[0], img.shape[1]
gray_img = img if img.ndim == 2 else cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
mask = gray_img > threshold
new_img = img[np.ix_(mask.any(1), mask.any(0))]
new_h, new_w = new_img.shape[0], new_img.shape[1]
if new_h == 0 or new_w == 0:
return img
# if any side is cropped more than 3-fold, return original image
if init_h / new_h > 3 or init_w / new_w > 3:
return img
else:
return new_img
# Ben's local brightness adjustement
# https://www.kaggle.com/c/diabetic-retinopathy-detection/discussion/15801#latest-370950
def bens_preprocess(image, size_is_min, new_size=512, sigmax=None):
image = resize(image, size_is_min, new_size)
if sigmax is None:
sigmax = min(image.shape[0], image.shape[1]) // 60
image = cv2.addWeighted(image, 4, cv2.GaussianBlur(image, (0, 0), sigmax), -4, 128)
return image
|
{"hexsha": "c3c522ad299cd3ee08543d4003637c00af986cb8", "size": 2042, "ext": "py", "lang": "Python", "max_stars_repo_path": "preprocessing/image_ops.py", "max_stars_repo_name": "wonderit/aptos-retinopathy-detection", "max_stars_repo_head_hexsha": "8402ce798fa0419627fb878788fa771849e34516", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "preprocessing/image_ops.py", "max_issues_repo_name": "wonderit/aptos-retinopathy-detection", "max_issues_repo_head_hexsha": "8402ce798fa0419627fb878788fa771849e34516", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "preprocessing/image_ops.py", "max_forks_repo_name": "wonderit/aptos-retinopathy-detection", "max_forks_repo_head_hexsha": "8402ce798fa0419627fb878788fa771849e34516", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4642857143, "max_line_length": 88, "alphanum_fraction": 0.597453477, "include": true, "reason": "import numpy", "num_tokens": 568}
|
From SyDPaCC.Tree Require Import
Skeletons Closure BTree.
From SyDPaCC.Bsml Require Import Model.Core Model.Pid Skeletons.StdLib.
From SyDPaCC.Core Require Import Bmf Parallelization.
Require Import Lia NArith.
Open Scope N_scope.
Module Make (Import Bsml : SyDPaCC.Bsml.Model.Core.BSML).
Module Pid := Pid.Make Bsml.Bsp.
Module StdLib := StdLib.Make Bsml Pid.
Module Import Skel := Tree.Skeletons.Make Bsml.
(* Set functions for the application of map *)
Definition kL_one {A} (x:A) := 1.
Definition kN_one {B} (x:B) := 1 .
Open Scope sydpacc_scope.
Definition spec_mapone {A B} : BTree.t A B -> BTree.t N N :=
BTree.map kL_one kN_one.
Typeclasses eauto := (bfs).
Definition mapone {A B} : PLTree A B -> PLTree N N:=
Eval sydpacc in
parallel(spec_mapone).
Close Scope sydpacc_scope.
End Make.
Close Scope N_scope.
|
{"author": "SyDPaCC", "repo": "sydpacc", "sha": "640f0f74f21524ee203b192255ecfa9e456fb7d1", "save_path": "github-repos/coq/SyDPaCC-sydpacc", "path": "github-repos/coq/SyDPaCC-sydpacc/sydpacc-640f0f74f21524ee203b192255ecfa9e456fb7d1/Tree/Applications/MapOne.v"}
|
"""Some custom helper types to make type hints and type checking easier.
For user facing type declarations, please see :py:func:`biopsykit.utils.datatype_helper`.
"""
from pathlib import Path
from typing import Hashable, Sequence, TypeVar, Union
import numpy as np
import pandas as pd
_Hashable = Union[Hashable, str]
path_t = TypeVar("path_t", str, Path) # pylint:disable=invalid-name
arr_t = TypeVar("arr_t", pd.DataFrame, pd.Series, np.ndarray) # pylint:disable=invalid-name
str_t = TypeVar("str_t", str, Sequence[str]) # pylint:disable=invalid-name
T = TypeVar("T")
|
{"hexsha": "5b1fddc4d202f434e11819bad248ea09142a7926", "size": 578, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/biopsykit/utils/_types.py", "max_stars_repo_name": "Zwitscherle/BioPsyKit", "max_stars_repo_head_hexsha": "7200c5f1be75c20f53e1eb4c991aca1c89e3dd88", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2020-11-05T13:34:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T16:20:10.000Z", "max_issues_repo_path": "src/biopsykit/utils/_types.py", "max_issues_repo_name": "Zwitscherle/BioPsyKit", "max_issues_repo_head_hexsha": "7200c5f1be75c20f53e1eb4c991aca1c89e3dd88", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2021-03-11T14:43:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-10T19:44:57.000Z", "max_forks_repo_path": "src/biopsykit/utils/_types.py", "max_forks_repo_name": "Zwitscherle/BioPsyKit", "max_forks_repo_head_hexsha": "7200c5f1be75c20f53e1eb4c991aca1c89e3dd88", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-09-13T13:14:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-19T09:13:25.000Z", "avg_line_length": 32.1111111111, "max_line_length": 92, "alphanum_fraction": 0.7508650519, "include": true, "reason": "import numpy", "num_tokens": 151}
|
import gym
import tensorflow as tf
import numpy as np
from collections import deque
from stable_baselines import logger
from stable_baselines.ppo2 import PPO2
from stable_baselines.ppo2.ppo2 import swap_and_flatten
from stable_baselines.common.callbacks import BaseCallback, CallbackList
from stable_baselines.asil.callbacks import EarlyStoppingCallback
from stable_baselines.asil.callbacks import LoggingCallback
from stable_baselines.asil.adversary import TransitionClassifier
from stable_baselines.asil.buffer import RewardBuffer
class ASIL(PPO2):
"""
Generative Adversarial Self-Imitation Learning (GASIL)
:param policy: (ActorCriticPolicy or str) The policy model to use (MlpPolicy, CnnPolicy, CnnLstmPolicy, ...)
:param env: (Gym environment or str) The environment to learn from (if registered in Gym, can be str)
:param gamma: (float) Discount factor
:param n_steps: (int) The number of steps to run for each environment per update
(i.e. batch size is n_steps * n_env where n_env is number of environment copies running in parallel)
:param ent_coef: (float) Entropy coefficient for the loss calculation
:param learning_rate: (float or callable) The learning rate, it can be a function
:param vf_coef: (float) Value function coefficient for the loss calculation
:param max_grad_norm: (float) The maximum value for the gradient clipping
:param lam: (float) Factor for trade-off of bias vs variance for Generalized Advantage Estimator
:param nminibatches: (int) Number of training minibatches per update. For recurrent policies,
the number of environments run in parallel should be a multiple of nminibatches.
:param noptepochs: (int) Number of epoch when optimizing the surrogate
:param cliprange: (float or callable) Clipping parameter, it can be a function
:param cliprange_vf: (float or callable) Clipping parameter for the value function, it can be a function.
This is a parameter specific to the OpenAI implementation. If None is passed (default),
then `cliprange` (that is used for the policy) will be used.
IMPORTANT: this clipping depends on the reward scaling.
To deactivate value function clipping (and recover the original PPO implementation),
you have to pass a negative value (e.g. -1).
:param verbose: (int) the verbosity level: 0 none, 1 training information, 2 tensorflow debug
:param tensorboard_log: (str) the log location for tensorboard (if None, no logging)
:param _init_setup_model: (bool) Whether or not to build the network at the creation of the instance
:param policy_kwargs: (dict) additional arguments to be passed to the policy on creation
:param full_tensorboard_log: (bool) enable additional logging when using tensorboard
WARNING: this logging can take a lot of space quickly
:param seed: (int) Seed for the pseudo-random generators (python, numpy, tensorflow).
If None (default), use random seed. Note that if you want completely deterministic
results, you must set `n_cpu_tf_sess` to 1.
:param n_cpu_tf_sess: (int) The number of threads for TensorFlow operations
If None, the number of cpu of the current machine will be used.
:param use_gasil: (bool) Whether or not to use GASIL Reward for learning
:param sil_samples: (int) Max Number of trajectories stored in SIL Buffer
:param sil_update: (int) The frequency of learning the Discriminator
:param adversary_step: (int) number of steps to train discriminator in each epoch
:param adversary_entcoeff: (float) the adversary entropy coefficient (1e-3)
:param sil_alpha: (float) the weight of the Discriminator Reward.
1 => just D (pure GASIL), 0 => just real reward (pure PPO)
:param adversary_stepsize: (float) the Adversarys stepsize on update
:param adversary_hidden_size: (int) the hidden dimension for the Discriminator Network (100)
"""
# sil_update=1, sil_value=0.01, sil_alpha=0.6, sil_beta=0.1,
def __init__(self, policy, env, gamma=0.99, n_steps=128, ent_coef=0.01, learning_rate=2.5e-4, vf_coef=0.5,
max_grad_norm=0.5, lam=0.95, nminibatches=4, noptepochs=4, cliprange=0.2, cliprange_vf=None,
verbose=0, tensorboard_log=None, _init_setup_model=True, policy_kwargs=None,
full_tensorboard_log=False, seed=None, n_cpu_tf_sess=None, threshold=None,
adversary_hidden_size=100, adversary_entcoeff=1e-3, sil_alpha=1.0,
sil_update=1, adversary_step=1, adversary_stepsize=3e-4, sil_samples=512,
use_gasil=True, terminate_on_solve=False, max_episodes=1000, **kwargs):
# super().__init__(policy, env, verbose=verbose, _init_setup_model=False, **kwargs)
logger.log("Init")
super().__init__(policy, env, gamma=gamma, n_steps=n_steps,
ent_coef=ent_coef, learning_rate=learning_rate,
vf_coef=vf_coef, max_grad_norm=max_grad_norm,
lam=lam, nminibatches=nminibatches,
noptepochs=noptepochs, cliprange=cliprange,
cliprange_vf=cliprange_vf, verbose=verbose,
tensorboard_log=tensorboard_log,
_init_setup_model=False, policy_kwargs=policy_kwargs,
full_tensorboard_log=full_tensorboard_log,
seed=seed, n_cpu_tf_sess=n_cpu_tf_sess, **kwargs)
# GAIL Params
self.use_gasil = use_gasil
self.sil_alpha = sil_alpha
self.sil_samples = sil_samples
self.sil_update = sil_update
self.buffer = RewardBuffer(size=sil_samples)
self.adversary = None
self.adversary_step = adversary_step
self.adversary_stepsize = adversary_stepsize
self.adversary_entcoeff = adversary_entcoeff
self.adversary_hidden_size = adversary_hidden_size
# Keep Track of Episode Reward (set, update, log from Callback)
self.real_reward = [] # Env Reward Buffer for Adapted Rollouts
self.d_reward = [] # Discriminator Reward Buffer for Adapted Rollouts
self.total_episodes = 0
self.current_episode = 0
self.moving_reward = deque([], maxlen=100)
self.terminate_on_solve = terminate_on_solve
self.max_episodes = max_episodes
self.stop = False
try:
self.threshold = float(threshold)
except Exception:
self.threshold = None
if terminate_on_solve:
logger.log(f"Stopping at {self.threshold}")
if _init_setup_model:
self.setup_model()
def setup_model(self):
logger.log("Setting Up PPO Model..")
super().setup_model()
logger.log("Adding Asil Dependencies..")
with self.graph.as_default():
self.adversary = TransitionClassifier(
self.observation_space, self.action_space,
self.adversary_hidden_size, self.sess,
self.train_model.obs_ph, self.action_ph,
stepsize=self.adversary_stepsize,
entcoeff=self.adversary_entcoeff)
self.params.extend(self.adversary.get_trainable_variables())
tf.global_variables_initializer().run(session=self.sess) # pylint: disable=E1101
self.summary = tf.summary.merge_all() # TODO test if needed / usable
self.adversary.setup_trainer()
def _train_step(self, learning_rate, cliprange, obs, returns, masks, actions, values, neglogpacs, update,
writer, states=None, cliprange_vf=None):
"""
Training of PPO2 Algorithm
:param learning_rate: (float) learning rate
:param cliprange: (float) Clipping factor
:param obs: (np.ndarray) The current observation of the environment
:param returns: (np.ndarray) the rewards
:param masks: (np.ndarray) The last masks for done episodes (used in recurent policies)
:param actions: (np.ndarray) the actions
:param values: (np.ndarray) the values
:param neglogpacs: (np.ndarray) Negative Log-likelihood probability of Actions
:param update: (int) the current step iteration
:param writer: (TensorFlow Summary.writer) the writer for tensorboard
:param states: (np.ndarray) For recurrent policies, the internal state of the recurrent model
:return: policy gradient loss, value function loss, policy entropy,
approximation of kl divergence, updated clipping range, training update operation
:param cliprange_vf: (float) Clipping factor for the value function
"""
# logger.log("Train Step from GASIL")
advs = returns - values
advs = (advs - advs.mean()) / (advs.std() + 1e-8)
td_map = {self.train_model.obs_ph: obs, self.action_ph: actions,
self.advs_ph: advs, self.rewards_ph: returns,
self.learning_rate_ph: learning_rate, self.clip_range_ph: cliprange,
self.old_neglog_pac_ph: neglogpacs, self.old_vpred_ph: values}
if states is not None:
td_map[self.train_model.states_ph] = states
td_map[self.train_model.dones_ph] = masks
# expert_obs, expert_acs, expert_rew, _ = self.buffer.sample(len(obs))
expert_obs, expert_acs, expert_rew = self.buffer.sample(len(obs))
td_map[self.adversary.expert_obs_ph] = expert_obs
td_map[self.adversary.expert_acs_ph] = expert_acs
td_map[self.adversary.expert_rew_ph] = expert_rew
td_map[self.adversary.generator_rew_ph] = returns.reshape((len(obs), 1))
if cliprange_vf is not None and cliprange_vf >= 0:
td_map[self.clip_range_vf_ph] = cliprange_vf
if states is None:
update_fac = max(self.n_batch // self.nminibatches // self.noptepochs, 1)
else:
update_fac = max(self.n_batch // self.nminibatches // self.noptepochs // self.n_steps, 1)
if writer is not None:
# run loss backprop with summary, but once every 10 runs save the metadata (memory, compute time, ...)
if self.full_tensorboard_log and (1 + update) % 10 == 0:
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
summary, policy_loss, value_loss, policy_entropy, approxkl, clipfrac, _ = self.sess.run(
[self.summary, self.pg_loss, self.vf_loss, self.entropy, self.approxkl, self.clipfrac, self._train],
td_map, options=run_options, run_metadata=run_metadata)
writer.add_run_metadata(run_metadata, 'step%d' % (update * update_fac))
else:
summary, policy_loss, value_loss, policy_entropy, approxkl, clipfrac, _ = self.sess.run(
[self.summary, self.pg_loss, self.vf_loss, self.entropy, self.approxkl, self.clipfrac, self._train],
td_map)
writer.add_summary(summary, (update * update_fac))
else:
policy_loss, value_loss, policy_entropy, approxkl, clipfrac, _ = self.sess.run(
[self.pg_loss, self.vf_loss, self.entropy, self.approxkl, self.clipfrac, self._train], td_map)
return policy_loss, value_loss, policy_entropy, approxkl, clipfrac
def learn(self, total_timesteps, callback=None, log_interval=100, tb_log_name="ASIL",
reset_num_timesteps=True):
env_name = self.env.envs[0].unwrapped.spec.id
if self.threshold is None:
self.threshold = self.env.envs[0].unwrapped.spec.reward_threshold
logging = LoggingCallback(env_name=env_name, verbose=self.verbose)
stopping = EarlyStoppingCallback(self.threshold, env_name, verbose=self.verbose)
learning = LeanAdversaryCallback(verbose=self.verbose)
callback = CallbackList([learning, logging, stopping])
return super().learn(
total_timesteps, callback=callback, log_interval=log_interval,
tb_log_name='', reset_num_timesteps=reset_num_timesteps)
def get_hparams(self):
return {
"gamma": self.gamma,
"n_steps": self.n_steps,
"vf_coef": self.vf_coef,
"ent_coef": self.ent_coef,
"max_grad_norm": self.max_grad_norm,
"learning_rate": self.learning_rate,
"lam": self.lam,
"nminibatches": self.nminibatches,
"noptepochs": self.noptepochs,
"cliprange": self.cliprange,
"cliprange_vf": self.cliprange_vf,
"verbose": self.verbose,
"policy": self.policy,
"observation_space": self.observation_space,
"action_space": self.action_space,
"n_envs": self.n_envs,
"n_cpu_tf_sess": self.n_cpu_tf_sess,
"seed": self.seed,
"_vectorize_action": self._vectorize_action,
"policy_kwargs": self.policy_kwargs,
"adversary_hidden_size": self.adversary_hidden_size,
"adversary_entcoeff": self.adversary_entcoeff,
"sil_update": self.sil_update,
"adversary_step": self.adversary_step,
"adversary_stepsize": self.adversary_stepsize,
"sil_samples": self.sil_samples,
"use_gasil": self.use_gasil
}
def save(self, save_path, cloudpickle=False):
# verbose=0, tensorboard_log=None, _init_setup_model=True, full_tensorboard_log=False,
data = self.get_hparams()
params_to_save = self.get_parameters()
self._save_to_file(save_path, data=data, params=params_to_save, cloudpickle=cloudpickle)
class LeanAdversaryCallback(BaseCallback):
"""
A custom callback Updating the Generative Adversarial Self-Imitation Extension
:param verbose: (int) Verbosity level 0: not output 1: info 2: debug
"""
def __init__(self, verbose=0):
super(LeanAdversaryCallback, self).__init__(verbose)
def _on_rollout_start(self) -> None:
"""
A rollout is the collection of environment interaction
using the current policy.
This event is triggered before collecting new samples.
"""
# Reset Discriminator Reward Buffer
self.model.d_rewards = []
def _on_step(self) -> bool:
"""
This method will be called by the model after each call to `env.step()`.
For child callback (of an `EventCallback`), this will be called
when the event is triggered.
:return: (bool) If the callback returns False, training is aborted early.
"""
observation = self.locals['mb_obs'][-1].copy()
action = self.locals['clipped_actions']
env_reward = self.locals['rewards']
reward = self.model.adversary.get_reward(observation, action[0], [env_reward])
# reward = 1 - self.model.adversary.get_reward(observation, action[0], [env_reward])
self.model.d_rewards.append(reward[0])
# For discounting D rewards after Rollout
if self.num_timesteps % self.model.n_steps == 0:
# Reshabe Discriminator Reward
d_rewards = np.asarray(self.model.d_rewards, dtype=np.float32)
mb_rewards = self.locals['mb_rewards'][:]
mb_rewards.append(self.locals['rewards'])
mb_rewards = np.asarray(mb_rewards, dtype=np.float32)
mb_values = np.asarray(self.locals['mb_values'], dtype=np.float32)
mb_dones = np.asarray(self.locals['mb_dones'], dtype=np.bool)
obs = self.locals['obs']
states = self.locals['states']
dones = self.locals['dones']
last_values = self.model.value(obs, states, dones)
# discount/bootstrap off value fn
# last_values = self.model.model.value(self.model.obs, self.model.states, self.model.dones)
d_adv = np.zeros_like(d_rewards)
d_true_reward = np.copy(d_rewards)
last_gae_lam = 0
for step in reversed(range(self.model.n_steps)):
if step == self.model.n_steps - 1:
nextnonterminal = 1.0 - dones # self.model.dones
nextvalues = last_values
else:
nextnonterminal = 1.0 - mb_dones[step + 1] # self.d_mb_dones[step + 1]
nextvalues = mb_values[step + 1] # self.d_mb_values[step + 1]
mixted_reward = self.model.sil_alpha * d_rewards[step] + (1-self.model.sil_alpha) * mb_rewards[step]
delta = mixted_reward + self.model.gamma * nextvalues * nextnonterminal - mb_values[step] # self.d_mb_values[step]
d_adv[step] = last_gae_lam = delta + self.model.gamma * self.model.lam * nextnonterminal * last_gae_lam
d_returns = d_adv + mb_values
d_returns, d_true_reward = map(swap_and_flatten, (d_returns, d_true_reward))
self.d_returns = d_returns
self.d_true_reward = d_true_reward
def _on_rollout_end(self) -> None:
"""
This event is triggered before updating the policy.
"""
if self.model.stop: # Prevent Early stopping error
return
# Get Variables
observations = self.locals['obs']
actions = self.locals['actions']
returns = self.locals['returns']
true_rewards = self.locals['true_reward']
masks = self.locals['masks']
writer = self.locals['writer']
n_steps = self.model.n_steps
# Calculate Discounted Return for rollout
G = true_rewards.copy()
gamma = self.model.gamma # 1
for step in reversed(range(self.model.n_steps)):
if step == self.model.n_steps - 1:
nextnonterminal = 1.0 - self.model.runner.dones
nextvalues = self.model.value(self.model.runner.obs,
self.model.runner.states,
self.model.runner.dones)
nextvalues = 0
else:
nextnonterminal = 1.0 - masks[step + 1]
nextvalues = G[step + 1]
G[step] = true_rewards[step] + gamma * nextvalues * nextnonterminal
# Update Buffer
rewards = G.reshape((n_steps, 1))
self.model.buffer.extend(observations, actions, rewards)
# Train Adversary
if (self.num_timesteps // n_steps) % self.model.sil_update == 0:
assert len(observations) == n_steps
batch_size = n_steps // self.model.adversary_step
d_losses = self.model.adversary.learn(
observations, actions, rewards, self.model.buffer, batch_size,
writer, self.num_timesteps
)
if self.model.use_gasil:
self.locals['true_reward'] = self.d_true_reward # d_rewards
self.locals['returns'] = self.d_returns # d_rewards
|
{"hexsha": "9db9bdb39d0160dcc69b594c9e88680a48d24e2f", "size": 19073, "ext": "py", "lang": "Python", "max_stars_repo_path": "stable_baselines/asil/asil.py", "max_stars_repo_name": "philippaltmann/ASIL", "max_stars_repo_head_hexsha": "d01d782e6fe0dd21ad2aadcb02f0f380732f81d7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "stable_baselines/asil/asil.py", "max_issues_repo_name": "philippaltmann/ASIL", "max_issues_repo_head_hexsha": "d01d782e6fe0dd21ad2aadcb02f0f380732f81d7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "stable_baselines/asil/asil.py", "max_forks_repo_name": "philippaltmann/ASIL", "max_forks_repo_head_hexsha": "d01d782e6fe0dd21ad2aadcb02f0f380732f81d7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.6883468835, "max_line_length": 131, "alphanum_fraction": 0.6518114612, "include": true, "reason": "import numpy", "num_tokens": 4414}
|
import slicer
import math
import numpy as np
from fMRSICore import MatLibraryClass as matLibraryClass
from fMRSICore import UnitClass as unitClass
class SpectrumClass(object):
""" properties """
""" % constantes """
STATUS_OK = 0;
FILE_ERROR = -1;
status = STATUS_OK ;
#figureArrangement = 24; # four up quantitative
figureArrangement = 26; # quantitative only
filterPoints = 11; # longitud en puntos de la senal de convolucion (combinacion bobinas)
"""
"""
""" end %%% properties %%% """
""" methods """
def __init__(self):
self.status = self.STATUS_OK;
self.matLibrary = matLibraryClass.MatLibraryClass();
self.unitObject = unitClass.UnitClass();
""" end % Constructor """
# U572_FM_Project_Get_Proc_Spectra_And_Sum
def calculateCombinedFrames(self):
### V2 - Error detectado. Correccion debajo.
#permutTransp = (self.matLibrary.permute(self.reshapedSignal.copy(),[2,1,0]))[0,:,:];
#self.combinedFrames = self.matLibrary.mean(permutTransp);
permutTransp = (self.matLibrary.permute(self.reshapedSignal.copy(),[2,1,0]));
self.combinedFrames = self.matLibrary.mean(permutTransp);
self.combinedFrames = self.combinedFrames[0,:,:]
self.combinedFrames = self.matLibrary.mean(self.combinedFrames);
### V2 - Calculo de bobinas combinadas.
permutTransp = (self.matLibrary.permute(self.reshapedSignal.copy(),[2,0,1]));
self.combinedCoils = self.matLibrary.mean(permutTransp);
self.combinedCoils = self.combinedCoils[0,:,:];
#% def calculateFramePower(self):
#%
#% Remarks: related to U585_FM_Project_Calculate_Frame_Power function (TRSV application)
#%
def calculateFramePower(self):
axis , pointRange = self.unitObject.getAxis({"centralFrequency":self.centralFrequency,"ppmReference":self.ppmReference,
"spectralBandwidth":self.spectralBandwidth,"spectrumLength":self.spectrumLength,
"range":self.unitObject.ALL, "units":self.unitObject.POINTS});
self.signalPower = np.sqrt(np.sum(np.real(self.combinedFrames)**2));
self.spectrumPower = np.sqrt(np.sum(np.real(self.combinedFrames)**2));
""" end %%% classdef FigureClass """
#% def coilCombination:
#%
#% Remarks: related to A604_FM_Project_Filter_PSignal_NW function (TRSV application)
#%
def coilCombination(self,signal):
signalShape = signal.shape;
rangeFilterPoints = self.matLibrary.transpose(range(0,self.filterPoints));
rangeSignalPoints = self.matLibrary.transpose(range(0,signalShape[0]));
pointAxis = rangeSignalPoints/float(signalShape[0]);
range3DGrid = self.matLibrary.repmat( pointAxis, [ 1,signalShape[1],signalShape[2]] );
gaussianFilter = np.exp(-self.filterWidth * (rangeFilterPoints / float(self.filterPoints-1) - 0.5)**2);
gaussianFilterSum = gaussianFilter.sum();
if gaussianFilterSum <= 0:
gaussianFilterSum = 1.0;
temporalSignal = signal / self.matLibrary.repmat(self.matLibrary.max(np.abs(signal)),[signalShape[0],1,1]);
signalSize = signal.size;
temporalSignal = self.matLibrary.reshape(temporalSignal,[signalSize,1]);
newSignal = np.convolve(np.reshape(temporalSignal,len(temporalSignal)),np.reshape(gaussianFilter,len(gaussianFilter)),mode='same')/float(gaussianFilterSum);
newSignal = self.matLibrary.reshape(newSignal, signal.shape);
temporalSignal= self.matLibrary.reshape(temporalSignal, signal.shape);
L1 = self.filterPoints;
L2 = signalShape[0]-1-L1;
newSignal[0:L1,:,:] = temporalSignal[0:self.filterPoints,:,:].copy();
newSignal[L2:,:,:] = temporalSignal[L2:,:,:].copy();
temporalSignal = [];
# Buscando pico de agua
dc_index = self.matLibrary.argmax(np.abs(np.fft.fft(newSignal,axis=0)),axis=0);
# Desplazamiento del espectro segun posicion del pico del agua
ref = np.exp(-1.0j * 2.0 * np.pi * range3DGrid * self.matLibrary.repmat(dc_index,[signalShape[0], 1 , 1]));
range3DGrid = [];
newSignal = newSignal * ref;
wyz = newSignal[0,:,:];
newSignalShape = newSignal.shape;
full_ref = ref.copy() ;
# zero-order phase
ex = np.exp(-1.0j * np.arctan2(np.imag(np.expand_dims(wyz,axis=0)),
np.real(np.expand_dims(wyz,axis=0))));
ref = self.matLibrary.repmat(ex,[signalShape[0],1,1]);
full_ref = full_ref * ref ;
newSignal = newSignal * ref;
# Unwrap de fase (paso 1)
ref = self.matLibrary.unwrap(np.arctan2(np.imag(newSignal),np.real(newSignal)),1.5*np.pi);
refShape = ref.shape;
ref = np.exp(-1.0j * self.matLibrary.repmat( rangeSignalPoints/float(signalShape[0]), [1,signalShape[1],signalShape[2]] ) *
self.matLibrary.repmat(np.expand_dims(ref[signalShape[0]-1,:,:],axis=0),[signalShape[0],1,1]));
full_ref = full_ref * ref ;
newSignal = newSignal * ref;
# HASTA AQUI VERIFICADO DIMENSIONES DE LOS OBJETOS
# Unwrap de fase (paso 2)
ref = self.matLibrary.unwrap(np.arctan2(np.imag(newSignal),np.real(newSignal)),1.5*np.pi);
newSignal = []
#Find the smooth spline through the phase, multiply by full_ref & signal.
sp = self.matLibrary.permute(self.matLibrary.csaps(pointAxis,self.matLibrary.permute(ref,[2,1,0]),0.9999,pointAxis,[],dtype=float),[2,1,0]);
NWS = signal * full_ref * np.exp(-1j * sp);
signal = [];
full_ref = [];
# Weighting factors applied to each coil
weo = self.matLibrary.max(np.abs(NWS[:,0,:]));
ss = np.sqrt(np.sum(weo**2));
weights = weo/ss;
shapeNWS = np.shape(NWS);
NWS = NWS * self.matLibrary.permute(self.matLibrary.repmat(weights,[shapeNWS[0],1,shapeNWS[1]]),[0,2,1]);
# ###############################
# FM Contribut-Eliminacion Agua.
if self.waterSuppression:
fac = 10.0**(-self.waterSuppressionFactor);
w = 2.0*fac**(-1.0*pointAxis/float(np.linalg.norm(pointAxis)));
fac = 1.0 - fac;
Smoothed = (self.waterSuppressionFactor/float(self.waterSupFactMax))*self.matLibrary.permute(
self.matLibrary.csaps(pointAxis,self.matLibrary.permute(NWS.copy(),[2,1,0]),
fac, pointAxis + self.matLibrary.eps(),w),[2,1,0]);
NWS = NWS - Smoothed;
# FM Contribut Pesos Equalizacion Frames. Posterior a posible
# eliminacion de agua, para que se reescale correctamente los
# maximos por frame
meanWeightbyframe = self.matLibrary.max(np.abs(self.matLibrary.transp(self.matLibrary.squeezeMean(self.matLibrary.permute(NWS,[2,1,0])))));
return NWS,weights,meanWeightbyframe;
def getCombinedFrames(self):
return self.combinedFrames;
#%
#% processSpectra(self,args):
#%
#% Remarks: related to U531_FM_Project_Process_Spectra function (TRSV application)
#%
def processSpectra(self,node,fMRSI):
self.spectrumData = fMRSI.sout;
self.spectrumDataLength = len(self.spectrumData);
self.centralFrequency = float(node.GetAttribute('centralFrequency'));
self.ppmReference = float(node.GetAttribute('ppmReference'));
self.spectrumLength = int(node.GetAttribute('spectrumLength'));
self.spectralBandwidth = float(node.GetAttribute('spectralBandwidth'));
self.totalFrames = int(node.GetAttribute('totalFrames'));
self.channels = int(node.GetAttribute('channels'));
self.zeroFrame = int(node.GetAttribute('zeroFrame'));
self.waterFrames = int(node.GetAttribute('waterFrames'));
# TODO: Tomar de la interfaz grafica
self.waterSupFactMax = 4.0 ;
self.waterSuppression = True;
self.waterSuppressionFactor = 3.85;
self.reshapedSignal = self.matLibrary.reshape(self.spectrumData,[self.spectrumDataLength,1]);
self.reshapedSignal = self.matLibrary.reshape(self.reshapedSignal,[self.spectrumLength,self.totalFrames,self.channels]);
self.waterSignals = self.reshapedSignal[:,self.zeroFrame:(self.waterFrames+1),:];
self.reshapedSignal = self.reshapedSignal[:,(self.waterFrames+self.zeroFrame):,:];
self.filterWidth = 20.0;
self.waterSignals,_,_ = self.coilCombination(self.waterSignals);
self.reshapedSignal, self.weights, self.meanWeightbyframe = self.coilCombination(self.reshapedSignal);
sz = np.shape(self.reshapedSignal);
self.normalWeights = self.weights/np.mean(self.weights);
nwSize = np.shape(self.normalWeights);
self.normalWeights = self.matLibrary.permute(self.matLibrary.reshape(self.normalWeights,[nwSize[1],1,1]),[2,1,0]);
self.normalWeights = self.matLibrary.repmat(self.normalWeights,[sz[0],sz[1],1]);
# U572_FM_Project_Get_Proc_Spectra_And_Sum;
self.calculateCombinedFrames();
self.calculateFramePower();
return self.combinedFrames, self.reshapedSignal, self.signalPower, self.spectrumPower, self.combinedCoils
|
{"hexsha": "70d1fdc4a84bb3eb572135774b83dea3ac30951d", "size": 10177, "ext": "py", "lang": "Python", "max_stars_repo_path": "PFileParser/fMRSICore/SpectrumClass.py", "max_stars_repo_name": "fmarcano/SlicerFMRSI", "max_stars_repo_head_hexsha": "e6c538938275fd6d917f2287fb0da49b67dcf6ef", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PFileParser/fMRSICore/SpectrumClass.py", "max_issues_repo_name": "fmarcano/SlicerFMRSI", "max_issues_repo_head_hexsha": "e6c538938275fd6d917f2287fb0da49b67dcf6ef", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PFileParser/fMRSICore/SpectrumClass.py", "max_forks_repo_name": "fmarcano/SlicerFMRSI", "max_forks_repo_head_hexsha": "e6c538938275fd6d917f2287fb0da49b67dcf6ef", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-06-26T10:40:51.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-26T10:40:51.000Z", "avg_line_length": 42.2282157676, "max_line_length": 165, "alphanum_fraction": 0.5954603518, "include": true, "reason": "import numpy", "num_tokens": 2467}
|
#define BOOST_TEST_DYN_LINK
#ifdef STAND_ALONE
#define BOOST_TEST_MODULE Main
#endif
#include <boost/test/unit_test.hpp>
#include "time_helper.h"
#include <iostream>
namespace r = reinforcement_learning;
BOOST_AUTO_TEST_CASE(time_usage) {
r::clock_time_provider ctp;
const uint16_t NUM_ITER = 1000;
for (int i = 0; i < NUM_ITER; ++i) {
const auto ts = ctp.gmt_now();
BOOST_CHECK(ts.year > 0);
BOOST_CHECK(ts.month <= 12);
BOOST_CHECK(ts.day <= 31);
BOOST_CHECK(ts.hour <= 23);
BOOST_CHECK(ts.minute <= 59);
BOOST_CHECK(ts.second <= 60);
BOOST_CHECK(ts.sub_second <= 9999999);
}
}
//BOOST_AUTO_TEST_CASE(time_loop) {
// r::clock_time_provider ctp;
// const uint16_t NUM_ITER = 1000;
// std::vector<reinforcement_learning::timestamp> ts_coll;
// for (int i = 0; i < NUM_ITER; ++i) {
// ts_coll.emplace_back(ctp.gmt_now());
// }
// for (auto && ts: ts_coll) {
// auto usec = ts.u_second % 1000;
// auto msec = ((ts.u_second - usec) % 1000000)/1000;
// auto total_sec = (ts.u_second - 1000 * msec - usec)/1000000;
// auto sec = total_sec % 60;
// auto min = (total_sec - sec)/60;
// std::cout << ts.month << "/" << ts.day << "/" << ts.year+1900 << " " << ts.hour << ":" << min << ":" << sec << "." << msec << "." << usec << std::endl;
// }
//}
|
{"hexsha": "cfe77c25d39163c9c0970dd2f2fc04c84334ab90", "size": 1290, "ext": "cc", "lang": "C++", "max_stars_repo_path": "unit_test/time_tests.cc", "max_stars_repo_name": "yannstad/reinforcement_learning", "max_stars_repo_head_hexsha": "29e5a4f786ed81ed2c9bc64ae6b14bdbf18b99e4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 63.0, "max_stars_repo_stars_event_min_datetime": "2018-10-22T17:11:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-08T17:26:41.000Z", "max_issues_repo_path": "unit_test/time_tests.cc", "max_issues_repo_name": "yannstad/reinforcement_learning", "max_issues_repo_head_hexsha": "29e5a4f786ed81ed2c9bc64ae6b14bdbf18b99e4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 160.0, "max_issues_repo_issues_event_min_datetime": "2018-10-09T02:34:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:43:48.000Z", "max_forks_repo_path": "unit_test/time_tests.cc", "max_forks_repo_name": "yannstad/reinforcement_learning", "max_forks_repo_head_hexsha": "29e5a4f786ed81ed2c9bc64ae6b14bdbf18b99e4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 36.0, "max_forks_repo_forks_event_min_datetime": "2018-10-08T21:44:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T16:20:03.000Z", "avg_line_length": 30.7142857143, "max_line_length": 155, "alphanum_fraction": 0.6279069767, "num_tokens": 398}
|
! Copyright 2020 Free Software Foundation, Inc.
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
program main
integer(4) :: arr1(-4294967297_8:-4294967296_8)
integer(4) :: arr2(4294967296_8:4294967297_8)
arr1 = 11
arr2 = 22
print *, 'arr1 = ', arr1
print *, 'arr2 = ', arr2
end
|
{"hexsha": "b72cd1bb2bccb4fd80c2d38bd85c799e75cdafa2", "size": 901, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "contrib/gnu/gdb/dist/gdb/testsuite/gdb.fortran/array-bounds-high.f90", "max_stars_repo_name": "TheSledgeHammer/2.11BSD", "max_stars_repo_head_hexsha": "fe61f0b9aaa273783cd027c7b5ec77e95ead2153", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-05-04T17:09:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-04T07:19:26.000Z", "max_issues_repo_path": "contrib/gnu/gdb/dist/gdb/testsuite/gdb.fortran/array-bounds-high.f90", "max_issues_repo_name": "TheSledgeHammer/2.11BSD", "max_issues_repo_head_hexsha": "fe61f0b9aaa273783cd027c7b5ec77e95ead2153", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "contrib/gnu/gdb/dist/gdb/testsuite/gdb.fortran/array-bounds-high.f90", "max_forks_repo_name": "TheSledgeHammer/2.11BSD", "max_forks_repo_head_hexsha": "fe61f0b9aaa273783cd027c7b5ec77e95ead2153", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.5416666667, "max_line_length": 71, "alphanum_fraction": 0.7192008879, "num_tokens": 238}
|
import quantum_circuit.gates
from quantum_circuit.gates import State
import quantum_circuit.gates_library as g_lib
import numpy as np
import math
from tests.testcase import BaseTestCase
class TestShor(BaseTestCase):
def test_shor(self):
# run test and see if errors are thrown
main()
def main():
# arbitrary number of qubits
qubit_count = 6
basis_size = 1 << qubit_count
# arbitrary key: 1000 - 1 gives the marked state
key = 0b000111
# optimal number of iterations of Grover step
n = math.floor(math.pi / (4 * math.asin(basis_size ** (-1 / 2))))
# initial state
state = State.from_basis_state(qubit_count, 0)
# matrix to apply the phase flip
flip_gate = g_lib.phase_flip_gate(qubit_count, key)
# matrix to apply diffusion
diff_gate = g_lib.diffusion_gate(qubit_count)
# matrix to apply Hadamard to every qubit
gate_list = [g_lib.hadamard() for i in range(qubit_count)]
H_n = quantum_circuit.MatrixGate.join_gates(qubit_count, gate_list)
# create superposition by applying Hadamard to every qubit
state = H_n(state)
# perform Grover step required number of times
full = flip_gate * diff_gate
for i in range(n - 1):
full *= flip_gate * diff_gate
# apply the matrix to get the final state
final = full(state)
print(final)
if __name__ == '__main__':
main()
|
{"hexsha": "3f0f8a8cabcedcc694a1f1d2e808183a1e6c21ae", "size": 1390, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_grover.py", "max_stars_repo_name": "mathisgerdes/Quantum_Computing_Project", "max_stars_repo_head_hexsha": "d83855003da7b45b0ea90e9b214d78c6d452379b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/test_grover.py", "max_issues_repo_name": "mathisgerdes/Quantum_Computing_Project", "max_issues_repo_head_hexsha": "d83855003da7b45b0ea90e9b214d78c6d452379b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2017-03-17T17:18:50.000Z", "max_issues_repo_issues_event_max_datetime": "2017-03-27T18:18:45.000Z", "max_forks_repo_path": "tests/test_grover.py", "max_forks_repo_name": "jacobfc/Quantum_Computing_Project", "max_forks_repo_head_hexsha": "d83855003da7b45b0ea90e9b214d78c6d452379b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-04-15T09:01:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-15T09:01:50.000Z", "avg_line_length": 29.5744680851, "max_line_length": 71, "alphanum_fraction": 0.6985611511, "include": true, "reason": "import numpy", "num_tokens": 368}
|
subroutine furlea(
i spavac,time1,time0,
m ii)
c
c + + + PURPOSE + + +
c This subprogram allows for lower end advance during the depletion
c and recession phases.
c
c Called from FURREC
c Author(s): E. R. Kottwitz
c Reference in User Guide: Chapter 12
c
c NOTE: THIS MODULE HAS NOT BEEN RECODED
c
c + + + PARAMETERS + + +
include 'pmxpln.inc'
include 'pmxsrg.inc'
include 'pxstep.inc'
c
c + + + ARGUMENT DECLARATIONS + + +
integer ii
real spavac,time1,time0
c
c + + + ARGUMENT DEFINITIONS + + +
c ii - primary kinematic wave calculation counter
c spavac - space averaging coefficient for flow area for current
c time
c time1 - time of current set of calculations (s)
c time0 - time of previous set of calculations (s)
c
c + + + COMMON BLOCKS + + +
include 'ciraflo.inc'
c read: aqcnst,aqexp
c
include 'cirfurr.inc'
c read: spavz
c modify: aflow(0:xsteps,2),infltr(0:xsteps,2),inoptm(0:xsteps),
c tadvan(0:xsteps),xpostn(0:xsteps)
c
include 'cirinfl.inc'
c read: kosta,kostf,kostk
c
c + + + LOCAL VARIABLES + + +
real deltax,ratio,tiavq
c
c + + + LOCAL DEFINITIONS + + +
c deltax - advance distance during the current time step (m)
c ratio - ratio of deltax to (location of next node - location of
c current node) (m/m)
c tiavq - time averaging coefficient for flow rate
c
c + + + DATA INITIALIZATIONS + + +
data tiavq/0.35/
c
c + + + END SPECIFICATIONS + + +
c
c Determine advance distance (deltax) and ratio of this distance to
c the interval between the next node and the current node
c
c ---- (WEPP Equation 12.14, solved for DELTAX)
deltax = (1.0-tiavq)*qflow(ii,2)*(time1-time0)/
1 (spavac*aflow(ii,2)+spavz*(infltr(ii,2)-infltr(ii,1)))
10 ratio = deltax/(xpostn(ii+1)-xpostn(ii))
c
c If next statement is true then shift current calculation
c boundary downslope. Linearly interpolate for inoptm(i) and
c adjust aflow, infltr, tadvan, and xpostn arrays.
c
if(ratio.le.0.5 .or. (ratio.lt.1.0 .and. ii.eq.xsteps-1))then
inoptm(ii) = inoptm(ii)+(inoptm(ii+1)-inoptm(ii))*ratio
xpostn(ii) = xpostn(ii)+deltax
tadvan(ii) = time1
aflow(ii,2) = 0.0
qflow(ii,2) = 0.0
c
c ---- (WEPP Equation 12.4, where tau=inoptm)
infltr(ii,1) = kostk*inoptm(ii)**kosta+kostf*inoptm(ii)
infltr(ii,2) = infltr(ii,1)
c
c If next statement is true then shift next calculation boundary
c upslope. Linearly interpolate for inoptm(i+1), adjust aflow,
c infltr, tadvan, and xpostn arrays.
c
elseif(ratio.gt.0.5 .and. ratio.lt.1.0 .and. ii.lt.(xsteps-1))then
ii = ii+1
inoptm(ii) = inoptm(ii-1)+(inoptm(ii)-inoptm(ii-1))*ratio
xpostn(ii) = xpostn(ii-1)+deltax
tadvan(ii) = time1
aflow(ii,2) = 0.0
qflow(ii,2) = 0.0
c
c ---- (WEPP Equation 12.4, where tau=inoptm)
infltr(ii,1) = kostk*inoptm(ii)**kosta+kostf*inoptm(ii)
infltr(ii,2) = infltr(ii,1)
c
c If none of the above statements is true then increment i.
c Linearly interpolate for tadvan(i) and aflow(i,2) and adjust
c infltr array
c
else
ii = ii+1
tadvan(ii) = time0+(time1-time0)/ratio
aflow(ii,2) = aflow(ii-1,2)*(ratio-1.0)/ratio
qflow(ii,2) = aqcnst*aflow(ii,2)**aqexp
c
c ---- (WEPP Equation 12.4, where tau=inoptm+time1-tadvan)
infltr(ii,2) = kostk*(inoptm(ii)+time1-tadvan(ii))**kosta+
1 kostf*(inoptm(ii)+time1-tadvan(ii))
c
c ---- (WEPP Equation 12.4 where tau=inoptm)
infltr(ii,1) = kostk*inoptm(ii)**kosta+kostf*inoptm(ii)
c
c If the next statement is true then adjust deltax and make next
c round of calculation boundary adjustments.
c
if(ii.lt.xsteps)then
deltax = deltax-(xpostn(ii)-xpostn(ii-1))
goto 10
endif
endif
c
return
end
|
{"hexsha": "f59150ff0b4d8505897e0add5e69381bb211a701", "size": 4261, "ext": "for", "lang": "FORTRAN", "max_stars_repo_path": "src/wepp2010.1/furlea.for", "max_stars_repo_name": "jarad/dep", "max_stars_repo_head_hexsha": "fe73982f4c70039e1a31b9e8e2d9aac31502f803", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-26T17:49:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-26T17:49:19.000Z", "max_issues_repo_path": "src/wepp2010.1/furlea.for", "max_issues_repo_name": "jarad/dep", "max_issues_repo_head_hexsha": "fe73982f4c70039e1a31b9e8e2d9aac31502f803", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2018-12-12T18:02:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T19:14:25.000Z", "max_forks_repo_path": "src/wepp2010.1/furlea.for", "max_forks_repo_name": "akrherz/idep", "max_forks_repo_head_hexsha": "7189a26fbcec3d8c3cc7d7015107b8fb6c5f6a45", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-03-02T22:59:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-09T15:49:00.000Z", "avg_line_length": 34.3629032258, "max_line_length": 73, "alphanum_fraction": 0.5820229993, "num_tokens": 1397}
|
theory Mg_Prod
imports "../Pord" "../Mergeable" "../Bump"
begin
(* For product types, we impose an ordering that requires that _all_ components of
* product a be less than or equal to their corresponding components of b,
* in order for a <[ b to hold.
*
* In other words, this is _not_ a lexicographic ordering. Lexicographic orderings
* where the first component is arbitrary create problems around completeness.
* This is why we work with a more restricted version of a lexicographic-like ordering, md_prio,
* a pair where the first component is guaranteed to be a natural number, and the ordering
* is lexicographic (see below)
*)
instantiation prod :: (Pord_Weak, Pord_Weak) Pord_Weak
begin
definition prod_pleq :
"(x :: 'a * 'b) <[ y =
(case x of
(x1, x2) \<Rightarrow> (case y of
(y1, y2) \<Rightarrow> (pleq x1 y1 \<and> pleq x2 y2)))"
instance proof
fix a :: "('a * 'b)"
show "pleq a a" by (auto simp add:prod_pleq leq_refl split:prod.splits)
next
fix a b c :: "('a * 'b)"
assume H1 : "pleq a b"
assume H2 : "pleq b c"
obtain a1 and a2 where 0 : "a = (a1, a2)" by (cases a; auto)
obtain b1 and b2 where 1 : "b = (b1, b2)" by (cases b; auto)
obtain c1 and c2 where 2 : "c = (c1, c2)" by (cases c; auto)
show "pleq a c" using H1 H2 0 1 2 leq_trans[of a1 b1 c1] leq_trans[of a2 b2 c2]
by (auto simp add:prod_pleq)
qed
end
instantiation prod :: (Pord, Pord) Pord
begin
instance proof
fix a b :: "('a * 'b)"
assume H1 : "pleq a b"
assume H2 : "pleq b a"
obtain a1 and a2 where 0 : "a = (a1, a2)" by (cases a; auto)
obtain b1 and b2 where 1 : "b = (b1, b2)" by (cases b; auto)
show "a = b" using H1 H2 0 1 leq_antisym[of a1 b1] leq_antisym[of a2 b2]
by(auto simp add:prod_pleq)
qed
end
instantiation prod :: (Pordc, Pordc) Pordc
begin
instance proof
fix a b :: "('a * 'b)"
assume H : "has_ub {a, b}"
obtain a1 and a2 where 0 : "a = (a1, a2)" by (cases a; auto)
obtain b1 and b2 where 1 : "b = (b1, b2)" by (cases b; auto)
obtain ub where HUb : "is_ub {a, b} ub" using H by (auto simp add:has_ub_def)
obtain ub1 and ub2 where HUb' : "ub = (ub1, ub2)" by (cases ub; auto)
have Ub1 : "is_ub {a1, b1} ub1" using H 0 1 HUb HUb'
by(auto simp add:prod_pleq is_ub_def)
have Ub2 : "is_ub {a2, b2} ub2" using H 0 1 HUb HUb'
by(auto simp add:prod_pleq is_ub_def)
obtain sup1 where Sup1 : "is_sup {a1, b1} sup1" using complete2[of a1 b1] Ub1
by(auto simp add: has_sup_def has_ub_def)
obtain sup2 where Sup2 : "is_sup {a2, b2} sup2"
using complete2[of a2 b2] Ub2
by(auto simp add: has_sup_def has_ub_def)
have Sup : "is_sup {(a1, a2), (b1, b2)} (sup1, sup2)" using Sup1 Sup2
by(auto simp add: prod_pleq is_sup_def is_ub_def is_least_def)
thus "has_sup {a, b}" using 0 1 by (auto simp add:has_sup_def)
qed
end
lemma is_sup_fst :
assumes Hnemp : "x \<in> Xs"
assumes H : "is_sup Xs supr"
shows "is_sup ((\<lambda> w . (w, x')) ` Xs) (supr, x')"
proof(rule is_supI)
fix x
assume X: "x \<in> (\<lambda>w. (w, x')) ` Xs"
then obtain x1 where X1 :
"x = (x1, x')" "x1 \<in> Xs"
by auto
have "x1 <[ supr"
using is_supD1[OF H X1(2)] by auto
then show "x <[ (supr, x')"
using X1
by(auto simp add: prod_pleq leq_refl)
next
fix y
assume Y: "is_ub ((\<lambda>w. (w, x')) ` Xs) y"
obtain y1 y2 where Y1_2 : "y = (y1, y2)"
by(cases y; auto)
have "is_ub Xs y1"
proof(rule is_ubI)
fix z
assume Z: "z \<in> Xs"
then have "(z, x') <[ y"
using is_ubE[OF Y] by auto
then show "z <[ y1"
using Y1_2
by(auto simp add: prod_pleq)
qed
then have "supr <[ y1"
using is_supD2[OF H]
by auto
have "(x, x') <[ y"
using is_ubE[OF Y] Hnemp
by auto
then have "x' <[ y2"
using Y1_2
by(auto simp add: prod_pleq)
show "(supr, x') <[ y"
using `supr <[ y1` `x' <[ y2` Y1_2
by(auto simp add: prod_pleq)
qed
lemma is_ub_fst :
assumes Hnemp : "x \<in> Xs"
assumes H : "is_ub Xs ub"
shows "is_ub ((\<lambda> w . (w, x')) ` Xs) (ub, x')"
proof(rule is_ubI)
fix x
assume X: "x \<in> (\<lambda>w. (w, x')) ` Xs"
then obtain x1 where X1 :
"x = (x1, x')" "x1 \<in> Xs"
by auto
have "x1 <[ ub"
using is_ubE[OF H X1(2)] by auto
then show "x <[ (ub, x')"
using X1
by(auto simp add: prod_pleq leq_refl)
qed
lemma is_sup_fst' :
assumes Hnemp : "xy \<in> Xys"
assumes H : "is_sup Xys (s1, s2)"
shows "is_sup (fst ` Xys) s1"
proof(rule is_supI)
fix x
assume X: "x \<in> fst ` Xys"
then obtain y where Xy : "(x, y) \<in> Xys"
by(auto)
then have "(x, y) <[ (s1, s2)"
using is_supD1[OF H Xy]
by auto
then show "x <[ s1"
by(auto simp add: prod_pleq)
next
fix x'
assume X' : "is_ub (fst ` Xys) x'"
have Ub' : "is_ub Xys (x', s2)"
proof(rule is_ubI)
fix w
assume W : "w \<in> Xys"
obtain w1 w2 where W1_2 :
"w = (w1, w2)"
by(cases w; auto)
then have "w1 \<in> fst ` Xys" using imageI[OF W, of fst]
by auto
then have "w1 <[ x'"
using is_ubE[OF X'] by auto
have "w2 \<in> snd ` Xys" using imageI[OF W, of snd] W1_2
by auto
then have "w2 <[ s2"
using is_supD1[OF H W] W1_2
by(auto simp add: prod_pleq)
then show "w <[ (x', s2)"
using `w1 <[ x'` W1_2
by(auto simp add: prod_pleq)
qed
show "s1 <[ x'"
using is_supD2[OF H Ub']
by(auto simp add: prod_pleq)
qed
lemma is_ub_fst' :
assumes Hnemp : "xy \<in> Xys"
assumes H : "is_ub Xys (s1, s2)"
shows "is_ub (fst ` Xys) s1"
proof(rule is_ubI)
fix x
assume X: "x \<in> fst ` Xys"
then obtain y where Xy : "(x, y) \<in> Xys"
by(auto)
then have "(x, y) <[ (s1, s2)"
using is_ubE[OF H Xy]
by auto
then show "x <[ s1"
by(auto simp add: prod_pleq)
qed
lemma is_sup_snd :
assumes Hnemp : "x \<in> Xs"
assumes H : "is_sup Xs supr"
shows "is_sup ((\<lambda> w . (x', w)) ` Xs) (x', supr)"
proof(rule is_supI)
fix x
assume X: "x \<in> (\<lambda>w. (x', w)) ` Xs"
then obtain x2 where X2 :
"x = (x', x2)" "x2 \<in> Xs"
by auto
have "x2 <[ supr"
using is_supD1[OF H X2(2)] by auto
then show "x <[ (x', supr)"
using X2
by(auto simp add: prod_pleq leq_refl)
next
fix y
assume Y: "is_ub ((\<lambda>w. (x', w)) ` Xs) y"
obtain y1 y2 where Y1_2 : "y = (y1, y2)"
by(cases y; auto)
have "is_ub Xs y2"
proof(rule is_ubI)
fix z
assume Z: "z \<in> Xs"
then have "(x', z) <[ y"
using is_ubE[OF Y] by auto
then show "z <[ y2"
using Y1_2
by(auto simp add: prod_pleq)
qed
then have "supr <[ y2"
using is_supD2[OF H]
by auto
have "(x', x) <[ y"
using is_ubE[OF Y] Hnemp
by auto
then have "x' <[ y1"
using Y1_2
by(auto simp add: prod_pleq)
show "(x', supr) <[ y"
using `supr <[ y2` `x' <[ y1` Y1_2
by(auto simp add: prod_pleq)
qed
lemma is_ub_snd :
assumes Hnemp : "x \<in> Xs"
assumes H : "is_ub Xs ub"
shows "is_ub ((\<lambda> w . (x', w)) ` Xs) (x', ub)"
proof(rule is_ubI)
fix x
assume X: "x \<in> (\<lambda>w. (x', w)) ` Xs"
then obtain x2 where X2 :
"x = (x', x2)" "x2 \<in> Xs"
by auto
have "x2 <[ ub"
using is_ubE[OF H X2(2)] by auto
then show "x <[ (x', ub)"
using X2
by(auto simp add: prod_pleq leq_refl)
qed
lemma is_sup_snd' :
assumes Hnemp : "xy \<in> Xys"
assumes H : "is_sup Xys (s1, s2)"
shows "is_sup (snd ` Xys) s2"
proof(rule is_supI)
fix y
assume Y: "y \<in> snd ` Xys"
then obtain x where Xy : "(x, y) \<in> Xys"
by(auto)
then have "(x, y) <[ (s1, s2)"
using is_supD1[OF H Xy]
by auto
then show "y <[ s2"
by(auto simp add: prod_pleq)
next
fix y'
assume Y' : "is_ub (snd ` Xys) y'"
have Ub' : "is_ub Xys (s1, y')"
proof(rule is_ubI)
fix w
assume W : "w \<in> Xys"
obtain w1 w2 where W1_2 :
"w = (w1, w2)"
by(cases w; auto)
then have "w2 \<in> snd ` Xys" using imageI[OF W, of snd]
by auto
then have "w2 <[ y'"
using is_ubE[OF Y'] by auto
have "w1 \<in> fst ` Xys" using imageI[OF W, of fst] W1_2
by auto
then have "w1 <[ s1"
using is_supD1[OF H W] W1_2
by(auto simp add: prod_pleq)
then show "w <[ (s1, y')"
using `w2 <[ y'` W1_2
by(auto simp add: prod_pleq)
qed
show "s2 <[ y'"
using is_supD2[OF H Ub']
by(auto simp add: prod_pleq)
qed
lemma is_ub_snd' :
assumes Hnemp : "xy \<in> Xys"
assumes H : "is_ub Xys (s1, s2)"
shows "is_ub (snd ` Xys) s2"
proof(rule is_ubI)
fix y
assume Y: "y \<in> snd ` Xys"
then obtain x where Xy : "(x, y) \<in> Xys"
by(auto)
then have "(x, y) <[ (s1, s2)"
using is_ubE[OF H Xy]
by auto
then show "y <[ s2"
by(auto simp add: prod_pleq)
qed
lemma is_sup_prod :
assumes Hx : "is_sup Xs suprx"
assumes Hy : "is_sup Ys supry"
assumes S1 : "fst ` S = Xs"
assumes S2 : "snd ` S = Ys"
shows "is_sup S (suprx, supry)"
proof(rule is_supI)
fix w
assume W_in : "w \<in> S"
obtain w1 w2 where W:
"w = (w1, w2)"
by(cases w; auto)
have W_Xs : "w1 \<in> Xs" and W_Ys : "w2 \<in> Ys"
using S1 S2 W_in W
using imageI[OF W_in, of fst] imageI[OF W_in, of snd]
by(auto)
have "w1 <[ suprx" "w2 <[ supry"
using is_supD1[OF Hx W_Xs] is_supD1[OF Hy W_Ys] W
by auto
then show "w <[ (suprx, supry)"
using W by(auto simp add: prod_pleq)
next
fix w'
assume Ub : "is_ub S w'"
obtain w'1 w'2 where W':
"w' = (w'1, w'2)"
by(cases w'; auto)
have Ub_Xs : "is_ub Xs w'1"
proof(rule is_ubI)
fix x
assume X : "x \<in> Xs"
then obtain y where Y: "(x, y) \<in> S"
using S1
by(auto)
have "(x, y) <[ w'"
using is_ubE[OF Ub Y]
by auto
then show "x <[ w'1"
using W'
by(auto simp add: prod_pleq)
qed
have Ub_Ys : "is_ub Ys w'2"
proof(rule is_ubI)
fix y
assume Y : "y \<in> Ys"
then obtain x where X: "(x, y) \<in> S"
using S2
by(auto)
have "(x, y) <[ w'"
using is_ubE[OF Ub X]
by auto
then show "y <[ w'2"
using W'
by(auto simp add: prod_pleq)
qed
have "suprx <[ w'1" "supry <[ w'2"
using is_supD2[OF Hx Ub_Xs] is_supD2[OF Hy Ub_Ys]
by auto
then show "(suprx, supry) <[ w'"
using W'
by(auto simp add: prod_pleq)
qed
lemma is_ub_prod :
assumes Hx : "is_ub Xs ubx"
assumes Hy : "is_ub Ys uby"
assumes S1 : "fst ` S = Xs"
assumes S2 : "snd ` S = Ys"
shows "is_ub S (ubx, uby)"
proof(rule is_ubI)
fix w
assume W_in : "w \<in> S"
obtain w1 w2 where W:
"w = (w1, w2)"
by(cases w; auto)
have W_Xs : "w1 \<in> Xs" and W_Ys : "w2 \<in> Ys"
using S1 S2 W_in W
using imageI[OF W_in, of fst] imageI[OF W_in, of snd]
by(auto)
have "w1 <[ ubx" "w2 <[ uby"
using is_ubE[OF Hx W_Xs] is_ubE[OF Hy W_Ys] W
by auto
then show "w <[ (ubx, uby)"
using W by(auto simp add: prod_pleq)
qed
instantiation prod :: (Pordps, Pordps) Pordps
begin
instance proof
fix a b c :: "'a * 'b"
assume "has_sup {a, b}"
then obtain sup_ab
where Sup_ab : "is_sup {a, b} sup_ab"
by(auto simp add: has_sup_def)
obtain sup_ab1 sup_ab2 where
Sup_ab12 : "sup_ab = (sup_ab1, sup_ab2)"
by(cases sup_ab; auto)
assume Sup_bc : "has_sup {b, c}"
then obtain sup_bc
where Sup_bc : "is_sup {b, c} sup_bc"
by(auto simp add: has_sup_def)
obtain sup_bc1 sup_bc2 where
Sup_bc12 : "sup_bc = (sup_bc1, sup_bc2)"
by(cases sup_bc; auto)
assume Sup_ac : "has_sup {a, c}"
then obtain sup_ac
where Sup_ac : "is_sup {a, c} sup_ac"
by(auto simp add: has_sup_def)
obtain sup_ac1 sup_ac2 where
Sup_ac12 : "sup_ac = (sup_ac1, sup_ac2)"
by(cases sup_ac; auto)
obtain a1 a2 where A: "a = (a1, a2)"
by(cases a; auto)
obtain b1 b2 where B: "b = (b1, b2)"
by(cases b; auto)
obtain c1 c2 where C: "c = (c1, c2)"
by(cases c; auto)
have Has_sup_ab1 :
"has_sup {a1, b1}"
using Sup_ab Sup_ab12 A B
is_sup_fst'[of a "{a, b}" sup_ab1 sup_ab2]
by(auto simp add: has_sup_def)
have Has_sup_ab2 :
"has_sup {a2, b2}"
using Sup_ab Sup_ab12 A B
is_sup_snd'[of a "{a, b}" sup_ab1 sup_ab2]
by(auto simp add: has_sup_def)
have Has_sup_bc1 :
"has_sup {b1, c1}"
using Sup_bc Sup_bc12 B C
is_sup_fst'[of b "{b, c}" sup_bc1 sup_bc2]
by(auto simp add: has_sup_def)
have Has_sup_bc2 :
"has_sup {b2, c2}"
using Sup_bc Sup_bc12 B C
is_sup_snd'[of b "{b, c}" sup_bc1 sup_bc2]
by(auto simp add: has_sup_def)
have Has_sup_ac1 :
"has_sup {a1, c1}"
using Sup_ac Sup_ac12 A C
is_sup_fst'[of a "{a, c}" sup_ac1 sup_ac2]
by(auto simp add: has_sup_def)
have Has_sup_ac2 :
"has_sup {a2, c2}"
using Sup_ac Sup_ac12 A C
is_sup_snd'[of a "{a, c}" sup_ac1 sup_ac2]
by(auto simp add: has_sup_def)
obtain sup1 where Sup1 :
"is_sup {a1, b1, c1} sup1"
using pairwise_sup[OF Has_sup_ab1 Has_sup_bc1 Has_sup_ac1]
by(auto simp add: has_sup_def)
obtain sup2 where Sup2 :
"is_sup {a2, b2, c2} sup2"
using pairwise_sup[OF Has_sup_ab2 Has_sup_bc2 Has_sup_ac2]
by(auto simp add: has_sup_def)
have "is_sup {a, b, c} (sup1, sup2)"
using is_sup_prod[OF Sup1 Sup2, of "{a, b, c}"]
unfolding A B C
by auto
then show "has_sup {a, b, c}"
by(auto simp add: has_sup_def)
qed
end
instantiation prod :: (Pordpsok, Pordpsok) Pordpsok
begin
instance proof
fix a b supr :: "('a * 'b)"
assume Aok : "a \<in> ok_S"
assume Bok : "b \<in> ok_S"
assume Sup : "is_sup {a, b} supr"
obtain a1 a2 where A : "a = (a1, a2)" "a1 \<in> ok_S" "a2 \<in> ok_S"
using Aok
by(cases a; auto simp add: prod_ok_S)
obtain b1 b2 where B : "b = (b1, b2)" "b1 \<in> ok_S" "b2 \<in> ok_S"
using Bok
by(cases b; auto simp add: prod_ok_S)
obtain supr1 supr2 where Supr12 : "supr = (supr1, supr2)"
by(cases supr; auto)
have Supr_fst : "is_sup {a1, b1} supr1"
using is_sup_fst'[of a "{a, b}" supr1 supr2] Sup
unfolding A B Supr12
by auto
then have Supr_fst_ok : "supr1 \<in> ok_S"
using pairwise_sup_ok[OF A(2) B(2) Supr_fst] by auto
have Supr_snd : "is_sup {a2, b2} supr2"
using is_sup_snd'[of a "{a, b}" supr1 supr2] Sup
unfolding A B Supr12
by auto
then have Supr_snd_ok : "supr2 \<in> ok_S"
using pairwise_sup_ok[OF A(3) B(3) Supr_snd] by auto
then show "supr \<in> ok_S"
using Supr_fst_ok Supr_snd_ok Supr12
by(auto simp add: prod_ok_S)
qed
end
instantiation prod :: (Pord_Weakb, Pord_Weakb) Pord_Weakb
begin
definition prod_bot :
"(bot :: 'a * 'b) = (bot, bot)"
instance proof
fix a :: "'a * 'b"
show "pleq bot a"
by(cases a; auto simp add:prod_pleq prod_bot bot_spec)
qed
end
instantiation prod :: (Pordb, Pordb) Pordb
begin
instance proof
qed
end
instantiation prod :: (Mergeableb, Mergeableb) Mergeableb
begin
definition prod_bsup :
"[^ a, b ^] =
(case a of
(a1, a2) \<Rightarrow> (case b of
(b1, b2) \<Rightarrow> (bsup a1 b1, bsup a2 b2)))"
instance proof
fix a :: "'a * 'b"
fix b :: "'a * 'b"
obtain a1 and a2 where Ha : "a = (a1, a2)" by(cases a; auto)
obtain b1 and b2 where Hb : "b = (b1, b2)" by(cases b; auto)
show "is_bsup a b (bsup a b)"
proof(rule is_bsupI)
show "pleq a (bsup a b)" using Ha Hb bsup_leq[OF bsup_spec[of a1 b1]] bsup_leq[OF bsup_spec[of a2 b2]]
by(auto simp add:prod_bsup prod_pleq split:prod.splits)
next
fix bd :: "'a * 'b"
fix sd :: "'a * 'b"
obtain a1 and a2 where Ha : "a = (a1, a2)" by(cases a; auto)
obtain b1 and b2 where Hb : "b = (b1, b2)" by(cases b; auto)
obtain bd1 and bd2 where Hbd : "bd = (bd1, bd2)" by(cases bd; auto)
obtain sd1 and sd2 where Hsd : "sd = (sd1, sd2)" by(cases sd; auto)
obtain bsupv1 and bsupv2 where Hbsup : "bsup a b = (bsupv1, bsupv2)" by (cases "(bsup a b)"; auto)
assume Hleq : "pleq bd b"
assume Hsup : "is_sup {a, bd} sd"
have Hbsv1 : "bsupv1 = bsup a1 b1" using Ha Hb Hbsup
by(auto simp add:prod_bsup)
have Hbsv2 : "bsupv2 = bsup a2 b2" using Ha Hb Hbsup
by(auto simp add:prod_bsup)
have Sup1 : "is_sup {a1, bd1} sd1" using Ha Hbd Hsd Hsup
by(auto simp add: prod_pleq is_sup_def is_least_def is_ub_def)
have Sup2 : "is_sup {a2, bd2} sd2" using Ha Hbd Hsd Hsup
by(auto simp add: prod_pleq is_sup_def is_least_def is_ub_def)
have Leq1 : "pleq bd1 b1" using Hb Hbd Hleq
by(auto simp add: prod_pleq is_sup_def is_least_def is_ub_def)
have Leq2 : "pleq bd2 b2" using Hb Hbd Hleq
by(auto simp add: prod_pleq is_sup_def is_least_def is_ub_def)
have Bsup1 : "is_bsup a1 b1 bsupv1" using Hbsup Ha Hb bsup_spec[of a1 b1]
by(auto simp add:prod_bsup)
have Bsup2 : "is_bsup a2 b2 bsupv2" using Hbsup Ha Hb bsup_spec[of a2 b2]
by(auto simp add:prod_bsup)
have Conc1 : "pleq sd1 (bsup a1 b1)" using is_bsupD2[OF Bsup1 Leq1 Sup1] Hbsv1
by(auto simp add:is_bsup_def is_least_def is_bub_def)
have Conc2 : "pleq sd2 (bsup a2 b2)" using is_bsupD2[OF Bsup2 Leq2 Sup2] Hbsv2
by(auto simp add:is_bsup_def is_least_def is_bub_def)
show "pleq sd (bsup a b)" using Ha Hb Hbsup Hbsv1 Hbsv2 Hsd Conc1 Conc2
by(auto simp add: prod_pleq prod_bsup)
next
fix x :: "'a * 'b"
obtain a1 and a2 where Ha : "a = (a1, a2)" by(cases a; auto)
obtain b1 and b2 where Hb : "b = (b1, b2)" by(cases b; auto)
obtain x1 and x2 where Hx : "x = (x1, x2)" by(cases x; auto)
obtain bsupv1 and bsupv2 where Hbsup : "bsup a b = (bsupv1, bsupv2)" by (cases "(bsup a b)"; auto)
have Hbsv1 : "bsupv1 = bsup a1 b1" using Ha Hb Hbsup
by(auto simp add:prod_bsup)
have Hbsv2 : "bsupv2 = bsup a2 b2" using Ha Hb Hbsup
by(auto simp add:prod_bsup)
assume Hbub : "is_bub a b x"
have Hbub1 : "is_bub a1 b1 x1"
proof(rule is_bubI)
show "pleq a1 x1" using Hbub Ha Hx by(auto simp add:is_bub_def is_sup_def prod_pleq)
next
fix bd1 :: 'a
fix sd1 :: 'a
assume H1 : "pleq bd1 b1"
assume H2 : "is_sup {a1,bd1} sd1"
have Hpleq' : "pleq (bd1, bot) b" using H1 Hb bot_spec[of b2]
by (auto simp add: prod_pleq)
have Hsup' : "is_sup {a, (bd1, bot)} (sd1, a2)" using Ha bot_spec[of a2] H2
by(auto simp add:is_sup_def is_least_def is_ub_def leq_refl prod_pleq)
show "pleq sd1 x1" using is_bubD2[OF Hbub Hpleq' Hsup'] Hx
by(simp add:prod_pleq)
qed
have Hbub2 : "is_bub a2 b2 x2"
proof(rule is_bubI)
show "pleq a2 x2" using Hbub Ha Hx by(auto simp add:is_bub_def is_sup_def prod_pleq)
next
fix bd2 :: 'b
fix sd2 :: 'b
assume H1 : "pleq bd2 b2"
assume H2 : "is_sup {a2,bd2} sd2"
have Hpleq' : "pleq (bot, bd2) b" using H1 Hb bot_spec[of b1]
by (auto simp add: prod_pleq)
have Hsup' : "is_sup {a, (bot, bd2)} (a1, sd2)" using Ha bot_spec[of a1] H2
by(auto simp add:is_sup_def is_least_def is_ub_def leq_refl prod_pleq)
show "pleq sd2 x2" using is_bubD2[OF Hbub Hpleq' Hsup'] Hx
by(simp add:prod_pleq)
qed
show "pleq (bsup a b) x" using Hx Ha Hb Hbub1 Hbub2 bsup_spec[of a1 b1] bsup_spec[of a2 b2]
by(auto simp add:is_bsup_def is_least_def prod_pleq prod_bsup)
qed
qed
end
instantiation prod :: (Pordc_all, Pordc_all) Pordc_all
begin
instance proof
fix a b :: "'a * 'b"
obtain a1 a2 where A: "a = (a1, a2)"
by(cases a; auto)
obtain b1 b2 where B: "b = (b1, b2)"
by(cases b; auto)
obtain ub1 where Ub1 : "is_ub {a1, b1} ub1"
using ub2_all[of a1 b1]
by(auto simp add: has_ub_def)
obtain ub2 where Ub2 : "is_ub {a2, b2} ub2"
using ub2_all[of a2 b2]
by(auto simp add: has_ub_def)
have "is_ub {a, b} (ub1, ub2)"
using is_ub_prod[OF Ub1 Ub2, of "{a, b}"]
unfolding A B
by auto
then show "has_ub {a, b}"
by(auto simp add: has_ub_def)
qed
end
instantiation prod :: (Bump, Bump) Bump
begin
definition prod_bump :
"bump x = (case x of (x1, x2) \<Rightarrow> (bump x1, bump x2))"
instance proof
fix x :: "'a * 'b"
show "bump x \<noteq> x"
by(cases x; auto simp add: prod_bump bump_neq)
next
fix x :: "'a * 'b"
show "x <[ bump x"
by(cases x; auto simp add: prod_bump prod_pleq bump_geq)
qed
end
end
|
{"author": "mmalvarez", "repo": "Gazelle", "sha": "0a80144107b3ec7487725bd88d658843beb6cb82", "save_path": "github-repos/isabelle/mmalvarez-Gazelle", "path": "github-repos/isabelle/mmalvarez-Gazelle/Gazelle-0a80144107b3ec7487725bd88d658843beb6cb82/Mergeable/Instances/Mg_Prod.thy"}
|
import os
import nltk
nltk.download('punkt')
nltk.download('wordnet')
import numpy
from tensorflow import keras
import random
import json
from nltk.stem.wordnet import WordNetLemmatizer
from nltk.stem.snowball import SnowballStemmer
scriptpath = os.path.abspath(__file__)
scriptdir = os.path.dirname(scriptpath)
INTENTS_PATH = os.path.join(scriptdir, 'intents.json')
MODEL_PATH = os.path.join(scriptdir, 'chatbot.h5')
with open(INTENTS_PATH) as intents:
intent_data = json.load(intents)
class ChatbotFunctions:
stemmer = None
lemmatizer = None
context = None
model = None
all_words = []
all_labels = []
all_patterns = []
all_responses = []
training = []
output = []
def __init__(self):
self.stemmer = SnowballStemmer("english")
self.lemmatizer = WordNetLemmatizer()
self.prep_data()
self.model = keras.models.load_model(MODEL_PATH)
def prep_data(self):
for intent in intent_data['intents']:
for pattern in intent['patterns']:
words = nltk.word_tokenize(pattern)
self.all_words.extend(words)
self.all_patterns.append(words)
self.all_responses.append(intent['tag'])
if intent['tag'] not in self.all_labels:
self.all_labels.append(intent['tag'])
self.all_words = [self.lemmatizer.lemmatize(word.lower()) for word in self.all_words]
self.all_words = [self.stemmer.stem(word.lower()) for word in self.all_words]
self.all_words = sorted(list(set(self.all_words)))
self.all_labels = sorted(self.all_labels)
def bag_of_words(self, text):
bag = [0 for _ in range(len(self.all_words))]
text_words = nltk.word_tokenize(text)
text_words = [self.lemmatizer.lemmatize(word.lower()) for word in text_words]
text_words = [self.stemmer.stem(word.lower()) for word in text_words]
for wrd in text_words:
for index, word in enumerate(self.all_words):
if word == wrd:
bag[index] = 1
return numpy.array(bag)
def chat(self, user_input):
default_responses = [
"Sorry, can't understand you, I am not perfect :'(", "Please give me more info :(", "Not sure I understand :(",
"Please be more specific", "Please provide me more information"
]
bag = self.bag_of_words(user_input)
bag = bag.reshape(1, -1)
results = self.model.predict([bag])[0]
result_index = numpy.argmax(results)
result_tag = self.all_labels[result_index]
if results[result_index] > 0.8:
if result_tag == 'goodbye' or result_tag == 'thanks':
responses = intent_data['intents'][1]['responses'] if result_tag == 'goodbye' else intent_data['intents'][5]['responses']
return random.choice(responses) + "\n"
for intent in intent_data['intents']:
if intent['tag'] == result_tag:
if 'context_filter' not in intent or 'context_filter' in intent and intent['context_filter'] == self.context:
responses = intent['responses']
if 'context' in intent:
self.context = intent['context']
else:
self.context = None
return random.choice(responses) + "\n"
if intent.get('direct_access'):
responses = intent['responses']
return random.choice(responses) + "\n"
return random.choice(default_responses) + "\n"
return random.choice(default_responses) + "\n"
|
{"hexsha": "b72ea6f06961554705caa4d0eb7f8d5a4c4a9ce0", "size": 3789, "ext": "py", "lang": "Python", "max_stars_repo_path": "api/bot/chatbot-deployment/ChatbotFunctions.py", "max_stars_repo_name": "Ammar-Raneez/SDGP-MEDIC-IN-ONE", "max_stars_repo_head_hexsha": "bffcc424a1cde4eaad012cfba6fbeeb4b12e75d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2020-12-21T19:22:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-04T15:09:06.000Z", "max_issues_repo_path": "api/bot/chatbot-deployment/ChatbotFunctions.py", "max_issues_repo_name": "Ammar-Raneez/SDGP-MEDIC-IN-ONE", "max_issues_repo_head_hexsha": "bffcc424a1cde4eaad012cfba6fbeeb4b12e75d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2020-12-21T19:19:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-23T02:48:12.000Z", "max_forks_repo_path": "api/bot/chatbot-deployment/ChatbotFunctions.py", "max_forks_repo_name": "Ammar-Raneez/SDGP-MEDIC-IN-ONE", "max_forks_repo_head_hexsha": "bffcc424a1cde4eaad012cfba6fbeeb4b12e75d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-05-06T14:12:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-06T14:12:36.000Z", "avg_line_length": 39.46875, "max_line_length": 137, "alphanum_fraction": 0.5935603061, "include": true, "reason": "import numpy", "num_tokens": 818}
|
using LinearAlgebra
function sigmoid(a)
return 1.0 / (1 + exp(-a))
end
function fit(x, t; alpha = 0.01, tau_max = 1000)
function CEE(w, x, t)
grad = zeros(size(w))
for i in 1:length(t)
ti = (t[i] > 0) ? 1 : 0
h = sigmoid(dot(w, x[i, :]))
grad += ((h - ti) * x[i, :])'
end
return grad / length(t)
end
c = size(t)[2]
w = []
x = hcat(ones(size(x)[1], 1), x)
for i in 1:c
if size(x)[1] != size(t[:, i])[1]#Processing when the matrix is organized by dependent variable
x = x'
end
w0 = ones(1, length(x[1, :]))
for j in 1:tau_max
grad = CEE(w0, x, t[:, i])
w0 -= alpha * grad
end
push!(w, w0)
end
return w
end
function forecast(x, w)
x = hcat(ones(size(x)[1], 1), x)
p = nothing
for i in 1 : size(x)[1]
tp = [sigmoid(dot(w[j, :][1], x[i, :])) for j in 1:size(w)[1]]
tp = tp'
(p == nothing) ? p = tp : p = vcat(p, tp)
end
return p
end
function predict(x, w)
x = hcat(ones(size(x)[1], 1), x)
p = []
for i in 1 : size(x)[1]
tp = [sigmoid(dot(w[j, :][1], x[i, :])) for j in 1:size(w)[1]]
tp = argmax(tp)
push!(p, tp)
end
return p
end
|
{"hexsha": "c6443455c31facba90bdd0c9c8840972cd0a27f9", "size": 1304, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/Classification/OVR.jl", "max_stars_repo_name": "QGMW22/Horse.jl", "max_stars_repo_head_hexsha": "77be589dbf047a029615dde7773360ebcb5d99b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-01-19T13:09:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-19T13:09:53.000Z", "max_issues_repo_path": "src/Classification/OVR.jl", "max_issues_repo_name": "QGMW22/Horse", "max_issues_repo_head_hexsha": "77be589dbf047a029615dde7773360ebcb5d99b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-01-21T13:52:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-21T13:52:40.000Z", "max_forks_repo_path": "src/Classification/OVR.jl", "max_forks_repo_name": "QGMW22/Horse", "max_forks_repo_head_hexsha": "77be589dbf047a029615dde7773360ebcb5d99b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.6037735849, "max_line_length": 105, "alphanum_fraction": 0.4509202454, "num_tokens": 459}
|
# Imports
import torch
from torch.utils.data import DataLoader, Dataset
from torchvision import datasets
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
from skimage.transform import resize as sk_resize
from skimage import exposure
warnings.filterwarnings('ignore', category=UserWarning)
class FerDataset(Dataset):
"""
Custom pytorch `Dataset` class implementation to load fer images dataset.
This class loads the images from the original fer raw csv file
"""
def __init__(self, data_dir, flag, transform=None):
"""
:param data_dir: path to the csv file containing the data
:param flag: string indicating which slice of data to load. In the fer csv file, there are 3 sets of data:
`Training`, `PublicTest`, `PrivateTest`
:param transform: torchvision `transforms.Compose` object containing transformation to be applied to images
"""
self.data = self._read_csv(data_dir, flag)
self.transform = transform
def __len__(self):
"""
:return: the size of the dataset
"""
return self.data.shape[0]
def __getitem__(self, idx):
"""
:param idx: retrieve the image and label at position `idx`
:return: 2 pytorch tensors representing the image and the label resp.
"""
im = np.array([
int(i) for i in self.data['pixels'].iloc[idx].split(' ')
]).reshape((48, 48))
lab = np.array(self.data['emotion'].iloc[idx]).astype(np.uint8)
if self.transform is not None:
im = self.transform(im).to(torch.float32)
lab = torch.from_numpy(lab).long()
return im, lab
@staticmethod
def _read_csv(path_to_csv, flag='Training'):
df = pd.read_csv(path_to_csv, sep=',')
return df.loc[df['Usage'] == flag]
def get_fer_dataloader(batch_size=256, data_dir='./fer2013.csv', flag='Training', from_csv=True,
data_transforms=None):
"""
Utility function to create a pytorch `DataLoader` to use for training
:param batch_size: int representing the size of data batches
:param data_dir: directory containing the data, the data could either be the path to the raw csv file,
or a directory containing 3 subdirectories : `Training`, `PublicTest` and `PrivateTest`, each containing
resp. train, validation and test image files.
:param flag: string representing the set to be loaded among : `Training`, `PublicTest` and `PrivateTest`
:param from_csv: boolean telling wether the data are from the raw csv file, or from image files
:param data_transforms: torchvision `transforms.Compose` object containing transformation to be applied to images
:return: pytorch `DataLoader` object to iterate through and get batches
"""
if from_csv:
image_dataset = FerDataset(data_dir, flag, data_transforms)
else:
image_dataset = datasets.ImageFolder(os.path.join(data_dir, flag), data_transforms)
shuffle = True if flag == 'Train' else False
dataloader = DataLoader(image_dataset, batch_size=batch_size, num_workers=8, shuffle=shuffle)
return dataloader
# Utility classes for applying custom transformations to images
class AddChannel(object):
def __call__(self, im):
return np.expand_dims(im, 2)
class HistEq(object):
def __call__(self, im):
return exposure.equalize_hist(im)
class ToRGB(object):
def __call__(self, im):
if len(im.shape) < 3:
im = np.expand_dims(im, 2)
return np.repeat(im, 3, axis=2)
class SkResize(object):
def __init__(self, size):
self.size = size
def __call__(self, im, size=None):
return sk_resize(im, self.size)
def display_examples_fer(df, label):
"""
Utility function for displaying some sample images for a given label
:param label: integer from 0 to 6
:return:
"""
dict_label = {
0: 'Angry',
1: 'Disgust',
2: 'Fear',
3: 'Happy',
4: 'Sad',
5: 'Surprise',
6: 'Neutral'
}
print('Sample images for class :', dict_label[label])
def pixels_to_array(pix):
return np.array([
int(i) for i in pix.split(' ')
]).reshape((48, 48))
# get indices where the given label is located
images = df.query("Usage=='Training' & emotion=={}".format(label)).sample(4)['pixels'].values
fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(10, 5))
ax = ax.ravel()
for idx, im in enumerate(images):
ax[idx].imshow(pixels_to_array(im), cmap='gray')
|
{"hexsha": "13f5bc52ea78ae2144c6893a9d35d976fc3228c3", "size": 4819, "ext": "py", "lang": "Python", "max_stars_repo_path": "emotion_detection/fer_data_utils.py", "max_stars_repo_name": "anmol-sinha-coder/DEmoClassi", "max_stars_repo_head_hexsha": "476e8ffe95312b302f02dd44d238d5c447e5b054", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2019-03-26T09:52:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T08:52:58.000Z", "max_issues_repo_path": "emotion_detection/fer_data_utils.py", "max_issues_repo_name": "docketrun/DEmoClassi", "max_issues_repo_head_hexsha": "0667fa5e29f02d7b00ec04004453be42773f7331", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2019-07-03T09:10:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-11T23:43:18.000Z", "max_forks_repo_path": "emotion_detection/fer_data_utils.py", "max_forks_repo_name": "docketrun/DEmoClassi", "max_forks_repo_head_hexsha": "0667fa5e29f02d7b00ec04004453be42773f7331", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2019-03-12T21:09:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T14:59:20.000Z", "avg_line_length": 32.5608108108, "max_line_length": 118, "alphanum_fraction": 0.6324963685, "include": true, "reason": "import numpy", "num_tokens": 1105}
|
section \<open>Static data dependence\<close>
theory DataDependence imports "../Basic/DynDataDependence" begin
context CFG_wf begin
definition data_dependence :: "'node \<Rightarrow> 'var \<Rightarrow> 'node \<Rightarrow> bool"
("_ influences _ in _" [51,0])
where data_dependences_eq:"n influences V in n' \<equiv> \<exists>as. n influences V in n' via as"
lemma data_dependence_def: "n influences V in n' =
(\<exists>a' as'. (V \<in> Def n) \<and> (V \<in> Use n') \<and>
(n -a'#as'\<rightarrow>* n') \<and> (\<forall>n'' \<in> set (sourcenodes as'). V \<notin> Def n''))"
by(auto simp:data_dependences_eq dyn_data_dependence_def)
end
end
|
{"author": "data61", "repo": "PSL", "sha": "2a71eac0db39ad490fe4921a5ce1e4344dc43b12", "save_path": "github-repos/isabelle/data61-PSL", "path": "github-repos/isabelle/data61-PSL/PSL-2a71eac0db39ad490fe4921a5ce1e4344dc43b12/SeLFiE/Example/afp-2020-05-16/thys/Slicing/StaticIntra/DataDependence.thy"}
|
-makelib xcelium_lib/xilinx_vip -sv \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi4stream_vip_axi4streampc.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi_vip_axi4pc.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/xil_common_vip_pkg.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi4stream_vip_pkg.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi_vip_pkg.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi4stream_vip_if.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/axi_vip_if.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/clk_vip_if.sv" \
"D:/Xilinx/Vivado/2018.2/data/xilinx_vip/hdl/rst_vip_if.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"D:/Xilinx/Vivado/2018.2/data/ip/xpm/xpm_cdc/hdl/xpm_cdc.sv" \
"D:/Xilinx/Vivado/2018.2/data/ip/xpm/xpm_fifo/hdl/xpm_fifo.sv" \
"D:/Xilinx/Vivado/2018.2/data/ip/xpm/xpm_memory/hdl/xpm_memory.sv" \
-endlib
-makelib xcelium_lib/xpm \
"D:/Xilinx/Vivado/2018.2/data/ip/xpm/xpm_VCOMP.vhd" \
-endlib
-makelib xcelium_lib/microblaze_v10_0_7 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/b649/hdl/microblaze_v10_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_microblaze_0_0/sim/design_1_microblaze_0_0.vhd" \
-endlib
-makelib xcelium_lib/axi_lite_ipif_v3_0_4 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/cced/hdl/axi_lite_ipif_v3_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/axi_intc_v4_1_11 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/2fec/hdl/axi_intc_v4_1_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_microblaze_0_axi_intc_0/sim/design_1_microblaze_0_axi_intc_0.vhd" \
-endlib
-makelib xcelium_lib/mdm_v3_2_14 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/5125/hdl/mdm_v3_2_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_mdm_1_0/sim/design_1_mdm_1_0.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_clk_wiz_1_0/design_1_clk_wiz_1_0_clk_wiz.v" \
"../../../bd/design_1/ip/design_1_clk_wiz_1_0/design_1_clk_wiz_1_0.v" \
-endlib
-makelib xcelium_lib/lib_cdc_v1_0_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/ef1e/hdl/lib_cdc_v1_0_rfs.vhd" \
-endlib
-makelib xcelium_lib/proc_sys_reset_v5_0_12 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/f86a/hdl/proc_sys_reset_v5_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_rst_clk_wiz_1_100M_0/sim/design_1_rst_clk_wiz_1_100M_0.vhd" \
-endlib
-makelib xcelium_lib/lib_pkg_v1_0_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/0513/hdl/lib_pkg_v1_0_rfs.vhd" \
-endlib
-makelib xcelium_lib/fifo_generator_v13_2_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/7aff/simulation/fifo_generator_vlog_beh.v" \
-endlib
-makelib xcelium_lib/fifo_generator_v13_2_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/7aff/hdl/fifo_generator_v13_2_rfs.vhd" \
-endlib
-makelib xcelium_lib/fifo_generator_v13_2_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/7aff/hdl/fifo_generator_v13_2_rfs.v" \
-endlib
-makelib xcelium_lib/lib_fifo_v1_0_11 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/6078/hdl/lib_fifo_v1_0_rfs.vhd" \
-endlib
-makelib xcelium_lib/blk_mem_gen_v8_4_1 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/67d8/simulation/blk_mem_gen_v8_4.v" \
-endlib
-makelib xcelium_lib/lib_bmg_v1_0_10 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/9340/hdl/lib_bmg_v1_0_rfs.vhd" \
-endlib
-makelib xcelium_lib/lib_srl_fifo_v1_0_2 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/51ce/hdl/lib_srl_fifo_v1_0_rfs.vhd" \
-endlib
-makelib xcelium_lib/axi_datamover_v5_1_19 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/ec8a/hdl/axi_datamover_v5_1_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/axi_vdma_v6_3_5 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/b37e/hdl/axi_vdma_v6_3_rfs.v" \
-endlib
-makelib xcelium_lib/axi_vdma_v6_3_5 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/b37e/hdl/axi_vdma_v6_3_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_vdma_0_0/sim/design_1_axi_vdma_0_0.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_addr_decode.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_read.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_reg.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_reg_bank.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_top.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_ctrl_write.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_ar_channel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_aw_channel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_b_channel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_cmd_arbiter.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_cmd_fsm.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_cmd_translator.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_fifo.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_incr_cmd.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_r_channel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_simple_fifo.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_wrap_cmd.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_wr_cmd_fsm.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_axi_mc_w_channel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_axic_register_slice.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_axi_register_slice.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_axi_upsizer.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_a_upsizer.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_carry_and.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_carry_latch_and.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_carry_latch_or.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_carry_or.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_command_fifo.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_comparator.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_comparator_sel.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_comparator_sel_static.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_r_upsizer.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/axi/mig_7series_v4_1_ddr_w_upsizer.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/clocking/mig_7series_v4_1_clk_ibuf.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/clocking/mig_7series_v4_1_infrastructure.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/clocking/mig_7series_v4_1_iodelay_ctrl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/clocking/mig_7series_v4_1_tempmon.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_arb_mux.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_arb_row_col.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_arb_select.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_cntrl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_common.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_compare.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_mach.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_queue.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_bank_state.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_col_mach.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_mc.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_rank_cntrl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_rank_common.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_rank_mach.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/controller/mig_7series_v4_1_round_robin_arb.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ecc/mig_7series_v4_1_ecc_buf.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ecc/mig_7series_v4_1_ecc_dec_fix.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ecc/mig_7series_v4_1_ecc_gen.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ecc/mig_7series_v4_1_ecc_merge_enc.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ecc/mig_7series_v4_1_fi_xor.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ip_top/mig_7series_v4_1_memc_ui_top_axi.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ip_top/mig_7series_v4_1_mem_intfc.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_byte_group_io.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_byte_lane.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_calib_top.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_if_post_fifo.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_mc_phy.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_mc_phy_wrapper.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_of_pre_fifo.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_4lanes.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ck_addr_cmd_delay.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_dqs_found_cal.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_dqs_found_cal_hr.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_init.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_cntlr.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_data.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_edge.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_lim.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_mux.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_po_cntlr.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_ocd_samp.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_oclkdelay_cal.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_prbs_rdlvl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_rdlvl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_tempmon.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_top.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_wrcal.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_wrlvl.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_phy_wrlvl_off_delay.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_prbs_gen.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_ddr_skip_calib_tap.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_cc.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_edge_store.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_meta.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_pd.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_tap_base.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/phy/mig_7series_v4_1_poc_top.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ui/mig_7series_v4_1_ui_cmd.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ui/mig_7series_v4_1_ui_rd_data.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ui/mig_7series_v4_1_ui_top.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/ui/mig_7series_v4_1_ui_wr_data.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/design_1_mig_7series_0_0_mig_sim.v" \
"../../../bd/design_1/ip/design_1_mig_7series_0_0/design_1_mig_7series_0_0/user_design/rtl/design_1_mig_7series_0_0.v" \
-endlib
-makelib xcelium_lib/axi_uartlite_v2_0_21 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/a15e/hdl/axi_uartlite_v2_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_uartlite_0_0/sim/design_1_axi_uartlite_0_0.vhd" \
-endlib
-makelib xcelium_lib/interrupt_control_v3_1_4 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/8e66/hdl/interrupt_control_v3_1_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/axi_iic_v2_0_20 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/df5e/hdl/axi_iic_v2_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_iic_0_0/sim/design_1_axi_iic_0_0.vhd" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/5bb9/hdl/sc_util_v1_0_vl_rfs.sv" \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/5160/hdl/sc_axi2sc_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_12/sim/bd_6f02_s00a2s_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_21/sim/bd_6f02_s01a2s_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_27/sim/bd_6f02_s02a2s_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_33/sim/bd_6f02_s03a2s_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/acc2/hdl/sc_sc2axi_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_37/sim/bd_6f02_m00s2a_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/28cb/hdl/sc_exit_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_43/sim/bd_6f02_m00e_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/f90c/hdl/sc_node_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_38/sim/bd_6f02_m00arn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_39/sim/bd_6f02_m00rn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_40/sim/bd_6f02_m00awn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_41/sim/bd_6f02_m00wn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_42/sim/bd_6f02_m00bn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_34/sim/bd_6f02_sawn_1.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_35/sim/bd_6f02_swn_1.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_36/sim/bd_6f02_sbn_1.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/afa8/hdl/sc_mmu_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_30/sim/bd_6f02_s03mmu_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/4521/hdl/sc_transaction_regulator_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_31/sim/bd_6f02_s03tr_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/d1fc/hdl/sc_si_converter_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_32/sim/bd_6f02_s03sic_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_28/sim/bd_6f02_sarn_2.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_29/sim/bd_6f02_srn_2.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_24/sim/bd_6f02_s02mmu_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_25/sim/bd_6f02_s02tr_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_26/sim/bd_6f02_s02sic_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_22/sim/bd_6f02_sarn_1.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_23/sim/bd_6f02_srn_1.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_18/sim/bd_6f02_s01mmu_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_19/sim/bd_6f02_s01tr_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_20/sim/bd_6f02_s01sic_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_13/sim/bd_6f02_sarn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_14/sim/bd_6f02_srn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_15/sim/bd_6f02_sawn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_16/sim/bd_6f02_swn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_17/sim/bd_6f02_sbn_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_9/sim/bd_6f02_s00mmu_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_10/sim/bd_6f02_s00tr_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_11/sim/bd_6f02_s00sic_0.sv" \
-endlib
-makelib xcelium_lib/smartconnect_v1_0 -sv \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/4e7b/hdl/sc_switchboard_v1_0_vl_rfs.sv" \
-endlib
-makelib xcelium_lib/xil_defaultlib -sv \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_4/sim/bd_6f02_arsw_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_5/sim/bd_6f02_rsw_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_6/sim/bd_6f02_awsw_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_7/sim/bd_6f02_wsw_0.sv" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_8/sim/bd_6f02_bsw_0.sv" \
-endlib
-makelib xcelium_lib/xlconstant_v1_1_5 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/f1c3/hdl/xlconstant_v1_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_0/sim/bd_6f02_one_0.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_1/sim/bd_6f02_psr0_0.vhd" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_2/sim/bd_6f02_psr_aclk_0.vhd" \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/ip/ip_3/sim/bd_6f02_psr_aclk1_0.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_axi_smc_1/bd_0/sim/bd_6f02.v" \
"../../../bd/design_1/ip/design_1_axi_smc_1/sim/design_1_axi_smc_1.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_rst_mig_7series_0_100M_1/sim/design_1_rst_mig_7series_0_100M_1.vhd" \
"../../../bd/design_1/ipshared/08da/IPSRC/TMDSEncoder.vhd" \
"../../../bd/design_1/ipshared/08da/IPSRC/SerializerN_1.vhd" \
"../../../bd/design_1/ipshared/08da/IPSRC/DVITransmitter.vhd" \
"../../../bd/design_1/ipshared/08da/IPSRC/hdmi_tx.vhd" \
"../../../bd/design_1/ip/design_1_HDMI_FPGA_ML_0_0/sim/design_1_HDMI_FPGA_ML_0_0.vhd" \
-endlib
-makelib xcelium_lib/v_tc_v6_1_12 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/6694/hdl/v_tc_v6_1_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_v_tc_0_0/sim/design_1_v_tc_0_0.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_AXI4_Stream_to_Video_0_0/src/axis2pix_fifo/sim/axis2pix_fifo.v" \
"../../../bd/design_1/ipshared/53fd/src/AXI4_Stream_to_Video_Out.v" \
"../../../bd/design_1/ip/design_1_AXI4_Stream_to_Video_0_0/sim/design_1_AXI4_Stream_to_Video_0_0.v" \
-endlib
-makelib xcelium_lib/v_vid_in_axi4s_v4_0_8 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/d987/hdl/v_vid_in_axi4s_v4_0_vl_rfs.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_v_vid_in_axi4s_0_0/sim/design_1_v_vid_in_axi4s_0_0.v" \
"../../../bd/design_1/ipshared/db64/IPSRC/cmos_decode_v1.v" \
"../../../bd/design_1/ipshared/db64/IPSRC/count_reset_v1.v" \
"../../../bd/design_1/ipshared/db64/IPSRC/OV_Sensor_ML.v" \
"../../../bd/design_1/ip/design_1_OV_Sensor_ML_0_0/sim/design_1_OV_Sensor_ML_0_0.v" \
"../../../bd/design_1/ip/design_1_clk_wiz_0_0/design_1_clk_wiz_0_0_clk_wiz.v" \
"../../../bd/design_1/ip/design_1_clk_wiz_0_0/design_1_clk_wiz_0_0.v" \
-endlib
-makelib xcelium_lib/util_vector_logic_v2_0_1 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/2137/hdl/util_vector_logic_v2_0_vl_rfs.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_util_vector_logic_0_0/sim/design_1_util_vector_logic_0_0.v" \
-endlib
-makelib xcelium_lib/generic_baseblocks_v2_1_0 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/b752/hdl/generic_baseblocks_v2_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/axi_infrastructure_v1_1_0 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/ec67/hdl/axi_infrastructure_v1_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/axi_register_slice_v2_1_17 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/6020/hdl/axi_register_slice_v2_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/axi_data_fifo_v2_1_16 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/247d/hdl/axi_data_fifo_v2_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/axi_crossbar_v2_1_18 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/15a3/hdl/axi_crossbar_v2_1_vl_rfs.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_xbar_0/sim/design_1_xbar_0.v" \
-endlib
-makelib xcelium_lib/lmb_v10_v3_0_9 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/78eb/hdl/lmb_v10_v3_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_dlmb_v10_0/sim/design_1_dlmb_v10_0.vhd" \
"../../../bd/design_1/ip/design_1_ilmb_v10_0/sim/design_1_ilmb_v10_0.vhd" \
-endlib
-makelib xcelium_lib/lmb_bram_if_cntlr_v4_0_15 \
"../../../../project_1.srcs/sources_1/bd/design_1/ipshared/92fd/hdl/lmb_bram_if_cntlr_v4_0_vh_rfs.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_dlmb_bram_if_cntlr_0/sim/design_1_dlmb_bram_if_cntlr_0.vhd" \
"../../../bd/design_1/ip/design_1_ilmb_bram_if_cntlr_0/sim/design_1_ilmb_bram_if_cntlr_0.vhd" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
"../../../bd/design_1/ip/design_1_lmb_bram_0/sim/design_1_lmb_bram_0.v" \
"../../../bd/design_1/sim/design_1.v" \
-endlib
-makelib xcelium_lib/xil_defaultlib \
glbl.v
-endlib
|
{"hexsha": "90622289a116c061894fca534214b052592b645c", "size": 28687, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "project_1/project_1.ip_user_files/sim_scripts/design_1/xcelium/run.f", "max_stars_repo_name": "qxynju2017/Nexys-Video-Microblaze-OV5640-HDMI-", "max_stars_repo_head_hexsha": "64392396aab6c6b92c05b818ebaad0c9aeacbf5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-16T07:49:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-16T07:49:01.000Z", "max_issues_repo_path": "project_1/project_1.ip_user_files/sim_scripts/design_1/xcelium/run.f", "max_issues_repo_name": "qxynju2017/Nexys-Video-Microblaze-OV5640-HDMI-", "max_issues_repo_head_hexsha": "64392396aab6c6b92c05b818ebaad0c9aeacbf5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "project_1/project_1.ip_user_files/sim_scripts/design_1/xcelium/run.f", "max_forks_repo_name": "qxynju2017/Nexys-Video-Microblaze-OV5640-HDMI-", "max_forks_repo_head_hexsha": "64392396aab6c6b92c05b818ebaad0c9aeacbf5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-08-19T01:13:11.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-19T01:13:11.000Z", "avg_line_length": 75.2939632546, "max_line_length": 144, "alphanum_fraction": 0.7777390456, "num_tokens": 11580}
|
import mylib
import ctypes
import numpy as np
print("Try test_empty:")
mylib.test_empty()
print("\nTry test_add:")
print(mylib.test_add(34.55, 23))
print("\nTry test_add_double:")
print(mylib.test_add_double(34.55, 43.0))
# Create a 25 elements array
numel = 25
data = (ctypes.c_int * numel)(*[x for x in range(numel)])
# Pass the above array and the array length to C:
print("\nTry passing an array of 25 integers to C:")
mylib.test_passing_array(data, numel)
print("data from Python after returning from C:")
for indx in range(numel):
print(data[indx], end=" ")
print("")
x = [0.0, 0.0, 0.0, 0.0]
y = [1.0, 2.0, 3.0, 4.0]
z = [3.2, 4.2, 5.2, 6.2]
xarr = (ctypes.c_double * len(x))(*x)
yarr = (ctypes.c_double * len(y))(*y)
zarr = (ctypes.c_double * len(z))(*z)
mylib.test_add_array(xarr, yarr, zarr, 4)
print("data from Python after returning from C:")
for indx in range(4):
print(xarr[indx], end=" ")
print("")
np_arr = np.ctypeslib.as_array(xarr)
print(np_arr)
npx = np.array(x).astype(np.float64)
npy = np.array(y).astype(np.float64)
npz = np.array(z).astype(np.float64)
xa = npx.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
ya = npy.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
za = npz.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
mylib.test_add_array(xa, ya, za, 4)
npx = np.ctypeslib.as_array(xa, shape=(4,))
print(npx)
mylib.test_axpby_double(xa, ya, za, 2.0, 2.0, 4)
npa = np.ctypeslib.as_array(xa, shape=(4,))
print(npa)
npx = np.array(x).astype(np.float32)
npy = np.array(y).astype(np.float32)
npz = np.array(z).astype(np.float32)
xb = npx.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
yb = npy.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
zb = npz.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
print(npx)
mylib.test_axpby_float(xb, yb, zb, 2.0, 2.0, 4)
npb = np.ctypeslib.as_array(xb, shape=(4,))
print(x)
print(npb)
print(npx)
|
{"hexsha": "33e0d55fe93cbffac3dd7206c100f592d0b16798", "size": 1911, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/C++/Core/Python/test_mylib.py", "max_stars_repo_name": "cesmix-mit/MDP", "max_stars_repo_head_hexsha": "746e4f4aead5911ddeda77b0d2c117e3b70cc5c4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-09-15T03:09:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-15T03:09:46.000Z", "max_issues_repo_path": "src/C++/Core/Python/test_mylib.py", "max_issues_repo_name": "cesmix-mit/MDP", "max_issues_repo_head_hexsha": "746e4f4aead5911ddeda77b0d2c117e3b70cc5c4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-24T16:11:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-24T16:11:07.000Z", "max_forks_repo_path": "src/C++/Core/Python/test_mylib.py", "max_forks_repo_name": "cesmix-mit/MDP", "max_forks_repo_head_hexsha": "746e4f4aead5911ddeda77b0d2c117e3b70cc5c4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.5533980583, "max_line_length": 57, "alphanum_fraction": 0.6860282575, "include": true, "reason": "import numpy", "num_tokens": 659}
|
\chapter*{Abstract}
Maximising the economic effectiveness of a wind farm is essential in making wind a more economic source of energy. This effectiveness can be increased through the reduction of operation and maintenance costs, which can be achieved through continuously monitoring the condition of wind turbines. An alternative to expensive condition monitoring systems, which can be uneconomical especially for older wind turbines, is to implement classification algorithms on supervisory control and data acquisition (SCADA) signals, which are collected in most wind turbines. Several publications were reviewed, which were all found to use separate algorithms to predict specific faults in advance. In reality, wind turbines tend to have multiple faults which may happen simultaneously and have correlations with one another. This project focusses on developing a methodology to predict multiple wind turbine faults in advance simultaneously by implementing classification algorithms on SCADA signals for a wind farm with 25 turbines rated at 2,500 kW, spanning a period of 30 months. The data, which included measurements of wind speed, active power and pitch angle, was labelled using corresponding downtime data to detect normal behaviour, faults and varying timescales before a fault occurs. Three different classification algorithms, namely decision trees, random forests and k nearest neighbours were tested using imbalanced and balanced training data, initially to optimise a number of hyperparameters. The random forest classifier produced the best results. Upon conducting a more detailed analysis on the performance of specific faults, it was found that the classifier was unable to detect the varying timescales before a fault with accuracy comparable to that of normal or faulty behaviour. This could have been due to the SCADA data, which are used as features, being unsuitable for detecting the faults, and there is potential to improve this by balancing only these classes.
\\[.5cm]
\noindent\textbf{\textit{Keywords:}} \keywords
|
{"hexsha": "bfb8a902622f582374fd84e422ad3694c9022d16", "size": 2051, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "docs/abstract.tex", "max_stars_repo_name": "nmstreethran/WindTurbineClassification", "max_stars_repo_head_hexsha": "b0ea6de909ccd5bb425cee291ca3c252c11df4eb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 34, "max_stars_repo_stars_event_min_datetime": "2019-03-01T21:24:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T09:59:17.000Z", "max_issues_repo_path": "docs/abstract.tex", "max_issues_repo_name": "nmstreethran/WindTurbineClassification", "max_issues_repo_head_hexsha": "b0ea6de909ccd5bb425cee291ca3c252c11df4eb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/abstract.tex", "max_forks_repo_name": "nmstreethran/WindTurbineClassification", "max_forks_repo_head_hexsha": "b0ea6de909ccd5bb425cee291ca3c252c11df4eb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2019-03-01T21:24:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-26T15:04:14.000Z", "avg_line_length": 341.8333333333, "max_line_length": 1973, "alphanum_fraction": 0.8298391029, "num_tokens": 373}
|
struct NNStatistics
units::String
arealUnits::String
area::Polygon
observedMeanDistance::Real
expectedMeanDistance::Real
nearestNeighbourIndex::Real
pointsCount::Real
zScore::Real
end
"""
analysis(data::F, area::Union{P, Nothing}=nothing, units::String="kilometers") where {F <: AbstractFeatureCollection, P <: AbstractPolygon}
Nearest Neighbor Analysis calculates an index based the average distances
between points in the dataset, thereby providing inference as to whether the
data is clustered, dispersed, or randomly distributed within the study area.
It returns a Polygon of the study area, with the results of
the analysis attached as part of of the `nearestNeighborAnalysis` property
of the study area's `properties`. The attached
[_z_-score](https://en.wikipedia.org/wiki/Standard_score) indicates how many
standard deviations above or below the expected mean distance the data's
observed mean distance is. The more negative, the more clustered. The more
positive, the more evenly dispersed. A _z_-score between -2 and 2 indicates
a seemingly random distribution. That is, within _p_ of less than 0.05, the
distribution appears statistically significantly neither clustered nor
dispersed.
**Remarks**
- Though the analysis will work on any FeatureCollection type, it
works best with Point collections.
- This analysis is **very** sensitive to the study area provided.
If no Polygon is passed as the study area, the function draws a box
around the data, which may distort the findings. This analysis works best
with a bounded area of interest within with the data is either clustered,
dispersed, or randomly distributed. For example, a city's subway stops may
look extremely clustered if the study area is an entire state. On the other
hand, they may look rather evenly dispersed if the study area is limited to
the city's downtown.
"""
function analysis(data::F, area::Union{P, Nothing}=nothing, units::String="kilometers") where {F <: AbstractFeatureCollection, P <: AbstractPolygon}
area == nothing && (area = bbox_polygon(bbox(data)[1]))
feats = []
for ft in data.features
push!(feats, centroid(ft.geometry))
end
n = length(feats)
obsDist = []
for (index, p) in enumerate(feats)
other = filter((f, i) -> i !== index, feats)
push!(obsDist, distance(p, nearestpoint(p, other).coordinates, units))
end
reduce((a, b) -> a + b, obsDist)
popDensity = n / convert_area(area(area), "meters", units)
expDist = 1 / (2 * sqrt(popDensity))
var = 0.26136 / (sqrt(n * popDensity))
return NNStatistics(units, units * "²", area, obsDist, expDist, obsDist / expDist, n, (obsDist - expDist) / var)
end
|
{"hexsha": "56ad33b06abaf0f062476104c172569abfc07146", "size": 2794, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "src/lib/NearestNeighbour.jl", "max_stars_repo_name": "visr/Turf.jl", "max_stars_repo_head_hexsha": "fe3a61fabe6d5b9e7f0197bf1820be25432c467d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2019-07-08T06:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T10:28:51.000Z", "max_issues_repo_path": "src/lib/NearestNeighbour.jl", "max_issues_repo_name": "visr/Turf.jl", "max_issues_repo_head_hexsha": "fe3a61fabe6d5b9e7f0197bf1820be25432c467d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2019-06-20T13:17:35.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-17T19:51:03.000Z", "max_forks_repo_path": "src/lib/NearestNeighbour.jl", "max_forks_repo_name": "visr/Turf.jl", "max_forks_repo_head_hexsha": "fe3a61fabe6d5b9e7f0197bf1820be25432c467d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2019-08-01T16:58:09.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-07T02:30:07.000Z", "avg_line_length": 38.8055555556, "max_line_length": 149, "alphanum_fraction": 0.7151037938, "num_tokens": 654}
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Implements a simple high/low pass filter for audio source separation
"""
from __future__ import division
import numpy as np
import scipy.signal
import mask_separation_base
from ideal_mask import IdealMask
class HighLowPassFilter(mask_separation_base.MaskSeparationBase):
"""
A simple high/low pass filter that creates a mask in the time frequency representation
"""
def __init__(self, input_audio_signal, high_pass_cutoff_hz, do_fir_filter=False,
force_recompute_stft=False,
mask_type=mask_separation_base.MaskSeparationBase.BINARY_MASK):
super(HighLowPassFilter, self).__init__(input_audio_signal=input_audio_signal,
mask_type=mask_type)
self.high_pass_cutoff_hz = high_pass_cutoff_hz
self.should_do_fir_filter = do_fir_filter
self.do_stft = force_recompute_stft
self.stft = None
self.high_pass_mask = None
self.low_pass_mask = None
self.high_pass_signal = None
self.low_pass_signal = None
def run(self):
"""
Returns:
"""
if self.should_do_fir_filter:
# This implementation is based off of the sci-py cookbook:
# https://scipy-cookbook.readthedocs.io/items/FIRFilter.html
# Set up filter parameters
nyquist_rate = self.audio_signal.sample_rate / 2
width = 5.0 / nyquist_rate # Hz
ripple_db = 60
# Convert cutoff frequency
cutoff_hz = self.high_pass_cutoff_hz / nyquist_rate # Hz
# Make the filter
filter_order, beta = scipy.signal.kaiserord(ripple_db, width)
filter_coeffs = scipy.signal.firwin(filter_order, cutoff_hz, window=('kaiser', beta))
# Apply the filter to every channel in the mixture
low_pass_array = []
for ch in self.audio_signal.get_channels():
low_pass_array.append(scipy.signal.lfilter(filter_coeffs, [1.0], ch))
# Make a new AudioSignal object with filtered signal
low_pass_array = np.array(low_pass_array)
self.low_pass_signal = self.audio_signal.make_copy_with_audio_data(low_pass_array,
verbose=False)
self.high_pass_signal = self.audio_signal - self.low_pass_signal
# Make masks
ideal_mask = IdealMask(self.audio_signal, [self.high_pass_signal, self.low_pass_signal],
mask_type=self.mask_type)
self.high_pass_mask, self.low_pass_mask = ideal_mask.run()
else:
# This is the more simple of the two filtering methods. Here we just zero out STFT bins
# Compute the spectrogram and find the closest frequency bin to the cutoff freq
self._get_stft()
closest_freq_bin = self.audio_signal.get_closest_frequency_bin(self.high_pass_cutoff_hz)
# Make masks
self.low_pass_mask = self.ones_mask(self.stft.shape)
self.low_pass_mask.mask[closest_freq_bin:, :, :] = 0
self.high_pass_mask = self.low_pass_mask.invert_mask()
self.result_masks = [self.low_pass_mask, self.high_pass_mask]
return self.result_masks
def _get_stft(self):
"""
Computes the spectrogram of the input audio signal
Returns:
"""
if not self.audio_signal.has_stft_data or self.do_stft:
self.stft = self.audio_signal.stft(overwrite=True)
else:
self.stft = self.audio_signal.stft_data
def make_audio_signals(self):
"""
Returns:
"""
if self.low_pass_mask is None or self.high_pass_mask is None:
raise ValueError('Must call run() before calling make_audio_signals()!')
if not self.should_do_fir_filter:
self.high_pass_signal = self.audio_signal.apply_mask(self.high_pass_mask)
self.high_pass_signal.istft(overwrite=True,
truncate_to_length=self.audio_signal.signal_length)
self.low_pass_signal = self.audio_signal.apply_mask(self.low_pass_mask)
self.low_pass_signal.istft(overwrite=True,
truncate_to_length=self.audio_signal.signal_length)
return self.low_pass_signal, self.high_pass_signal
|
{"hexsha": "e0136bb10914166b84c838e0666b9a3f3e5fa2c4", "size": 4524, "ext": "py", "lang": "Python", "max_stars_repo_path": "build/lib/nussl/separation/high_low_pass_filter.py", "max_stars_repo_name": "KingStorm/nussl", "max_stars_repo_head_hexsha": "78edfdaad16845fc705cefb336a7e6e5923fbcd4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-22T19:30:45.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-22T19:30:45.000Z", "max_issues_repo_path": "dataHelper/nussl/separation/high_low_pass_filter.py", "max_issues_repo_name": "AleXander-Tsui/Audio-Localization-and-Seperation", "max_issues_repo_head_hexsha": "17d40e72b406d62ca5cb695938b50c6412f9524a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dataHelper/nussl/separation/high_low_pass_filter.py", "max_forks_repo_name": "AleXander-Tsui/Audio-Localization-and-Seperation", "max_forks_repo_head_hexsha": "17d40e72b406d62ca5cb695938b50c6412f9524a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.192, "max_line_length": 100, "alphanum_fraction": 0.6337312113, "include": true, "reason": "import numpy,import scipy", "num_tokens": 918}
|
import os
import sys
import numpy as np
from PIL import Image
num=1
path ="/Users/pection/Documents/mn_furniture/AddwatermarkProgram/Lastday/"
#we shall store all the file names in this list
filelist=[]
for root, dirs, files in os.walk(path):
for file in files:
if(file.endswith(".jpg")):
filelist.append(os.path.join(root,file))
print (filelist)
logo=Image.open('logo.png')
logo2=Image.open('logo2.png')
watermark = Image.open('WatermarkB5.png')
watermark2 = Image.open('WatermarkB3.png')
logoWidth = watermark.width
logoHeight = watermark.height
watermarkW=watermark.width
watermarkH=watermark.height
logo2Width = watermark2.width
logo2Height = watermark2.height
for filename in filelist:
image = Image.open(filename)
# imageWidth = image.width
# imageHeight = image.height
# if imageWidth<500 :
# img_w, img_h = image.size
# bg_w, bg_h = watermark2.size
# offset = ((bg_w - img_w) // 2, (bg_h - img_h) // 2)
# image.paste(logo2, (0, 0), logo2)
# image2=image.copy()
# image2.paste(watermark2,(int((img_w-logo2Width)/2),int((img_h-logo2Height)/2)),watermark2)
# else :
# img_w, img_h = image.size
# bg_w, bg_h = watermark.size
# offset = ((bg_w - img_w) // 2, (bg_h - img_h) // 2)
# image.paste(logo, (0, 0), logo)
# image2=image.copy()
# image2.paste(watermark,(int((img_w-logoWidth)/2),int((img_h-logoHeight)/2)),watermark)
num += 1
# image.save(filename)
image.save('/Users/pection/Documents/mn_furniture/AddwatermarkProgram/Extract/'+str(num)+'.png')
|
{"hexsha": "dd7f9dbcfe5bd13ce56beb5ae807d4bb63f3c4df", "size": 1609, "ext": "py", "lang": "Python", "max_stars_repo_path": "Program_python/Extractfolderimage.py", "max_stars_repo_name": "pection/MN-furniture", "max_stars_repo_head_hexsha": "4c796f072662c15b2a263272ef2637e221c42cab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-22T06:20:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-22T06:20:56.000Z", "max_issues_repo_path": "Program_python/Extractfolderimage.py", "max_issues_repo_name": "pection/MN-furniture", "max_issues_repo_head_hexsha": "4c796f072662c15b2a263272ef2637e221c42cab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Program_python/Extractfolderimage.py", "max_forks_repo_name": "pection/MN-furniture", "max_forks_repo_head_hexsha": "4c796f072662c15b2a263272ef2637e221c42cab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-11-24T18:18:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-24T18:18:42.000Z", "avg_line_length": 35.7555555556, "max_line_length": 100, "alphanum_fraction": 0.6619018024, "include": true, "reason": "import numpy", "num_tokens": 482}
|
from __future__ import print_function
import numpy as np
import tensorflow as tf
import sklearn.metrics
# Import MNIST data
from tensorflow.examples.tutorials.mnist import input_data
def readData(filename):
with open(filename, 'r') as f:
string = [line.strip().split('\t') for line in f.readlines()]
X = [map(float, line[:-1]) for line in string]
Y = [int(line[-1]) for line in string]
return np.array(X), np.array(Y)
def one_hot(Y,length):
NewY=[]
for i in range(len(Y)):
content=[]
num=Y[i]
for i in range(num):
content.append(0)
content.append(1)
for i in range(num+1,length):
content.append(0)
NewY.append(content)
return np.array(NewY)
def init(X, Y):
assert X.shape[0] == Y.shape[0], 'shape not match'
num_all = X.shape[0]
num_train = int(0.7 * num_all)
num_test = num_all - num_train
# shuffle
mask = np.random.permutation(num_all)
X = X[mask]
Y = Y[mask]
# training data
mask_train = range(num_train)
X_train = X[mask_train]
Y_train = Y[mask_train]
#testing data
mask_test = range(num_train, num_all)
X_test = X[mask_test]
Y_test = Y[mask_test]
print('All data shape: ', X.shape)
print('Train data shape: ', X_train.shape)
print('Train label shape: ', Y_train.shape)
print('Test data shape: ', X_test.shape)
print('Test label shape: ', Y_test.shape)
return X_train, Y_train, X_test, Y_test
X,Y=readData("../../data/finalData.txt")
Y=one_hot(Y,79)
X_train, Y_train, X_test, Y_test=init(X,Y)
xtr = tf.placeholder("float", [None, 453])
xte = tf.placeholder("float", [453])
distance = tf.reduce_sum(tf.abs(tf.add(xtr, tf.negative(xte))), reduction_indices=1)
#distance = tf.reduce_sum(tf.sqrt(tf.square(tf.add(xtr, tf.negative(xte)))), reduction_indices=1)
pred = tf.arg_min(distance, 0)
accuracy = 0.
pred_class = []
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for i in range(len(X_test)):
nn_index = sess.run(pred, feed_dict={xtr: X_train, xte: X_test[i, :]})
print("Test", i, "Prediction:", np.argmax(Y_train[nn_index]), \
"True Class:", np.argmax(Y_test[i]))
pred_class.append(Y_train[nn_index])
if np.argmax(Y_train[nn_index]) == np.argmax(Y_test[i]):
accuracy += 1./len(X_test)
print("Done!")
print("Accuracy:", accuracy)
print('F1 score: %f' % sklearn.metrics.f1_score(Y_test, np.array(pred_class), average='weighted'))
|
{"hexsha": "b342df6655d48103222dd408514e69bb3613f130", "size": 2589, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/knn/knn.py", "max_stars_repo_name": "ZhengtianXu/Gene_Chip", "max_stars_repo_head_hexsha": "f7b8e84bdaf8963923de16443fac22ce11df5714", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 17, "max_stars_repo_stars_event_min_datetime": "2017-11-24T00:22:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-16T06:11:57.000Z", "max_issues_repo_path": "src/knn/knn.py", "max_issues_repo_name": "ZhengtianXu/Gene_Chip", "max_issues_repo_head_hexsha": "f7b8e84bdaf8963923de16443fac22ce11df5714", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/knn/knn.py", "max_forks_repo_name": "ZhengtianXu/Gene_Chip", "max_forks_repo_head_hexsha": "f7b8e84bdaf8963923de16443fac22ce11df5714", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-06-24T09:04:35.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-24T09:04:35.000Z", "avg_line_length": 30.8214285714, "max_line_length": 102, "alphanum_fraction": 0.6299729625, "include": true, "reason": "import numpy", "num_tokens": 692}
|
[STATEMENT]
lemma PsiInv_alpha1: "\<turnstile> alpha1 \<and> $PsiInv \<longrightarrow> PsiInv$"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<turnstile> alpha1 \<and> $PsiInv \<longrightarrow> PsiInv$
[PROOF STEP]
by (auto simp: alpha1_def PsiInv_defs)
|
{"llama_tokens": 103, "file": null, "length": 1}
|
[STATEMENT]
lemma [code abstract]:
"integer_of_natural (m - n) = max 0 (integer_of_natural m - integer_of_natural n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. integer_of_natural (m - n) = max 0 (integer_of_natural m - integer_of_natural n)
[PROOF STEP]
by transfer simp
|
{"llama_tokens": 107, "file": null, "length": 1}
|
using Test
using JSON3
using Pinecone
APIKEY = ENV["PINECONE_API_KEY"]
CLOUDENV="us-west1-gcp"
context = Pinecone.init(APIKEY, CLOUDENV)
INDEX = "filter-example"
NAMESPACE = "mynamespace"
index = Pinecone.Index(INDEX);
@testset verbose = true "Create/Delete" begin
testindexname = "unittestindex"
@testset "Create" begin
#delete in case already present from previous failure
result = Pinecone.delete_index(context, Pinecone.Index(testindexname))
#sleep to wait for delete to go thru, backend takes a bit
sleep(10)
indexconfig = Dict{String, Any}("k_bits"=>512, "hybrid"=>true)
result = Pinecone.create_index(context, testindexname, 10, metric="euclidean", indextype="approximated",pods=1,replicas=2, shards=1, indexconfig=indexconfig)
println("CREATE(): ", result)
@test result == true
#max dims is 10000, check you cannot create 10001
@test_throws ArgumentError Pinecone.create_index(context, testindexname, 10001)
#broken pod type
@test_throws ArgumentError Pinecone.create_index(context, "shouldfail", 10, metric="euclidean", indextype="approximated",pods=1,replicas=2, shards=1, podtype="fail", indexconfig=indexconfig)
#bad pods
@test_throws ArgumentError Pinecone.create_index(context, "shouldfail", 10, metric="euclidean", indextype="approximated",pods=0,replicas=2, shards=1, podtype="p1", indexconfig=indexconfig)
#bad shards
@test_throws ArgumentError Pinecone.create_index(context, "shouldfail", 10, metric="euclidean", indextype="approximated",pods=1,replicas=2, shards=0, podtype="p1", indexconfig=indexconfig)
#bad pods and shards
@test_throws ArgumentError Pinecone.create_index(context, "shouldfail", 10, metric="euclidean", indextype="approximated",pods=0,replicas=2, shards=0, podtype="p1", indexconfig=indexconfig)
#bad metric
@test_throws ArgumentError Pinecone.create_index(context, "shouldfail", 10, metric="badmetric", indextype="approximated",pods=1,replicas=2, shards=1, podtype="p1", indexconfig=indexconfig)
end
@testset "Delete" begin
result = Pinecone.delete_index(context, Pinecone.Index(testindexname))
println("DELETE(): ", result)
@test result == true
end
end
|
{"hexsha": "af6b951ba6def5978beab9bd842468fded56664a", "size": 2286, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "test/testcreatedelete.jl", "max_stars_repo_name": "tullytim/Pinecone.jl", "max_stars_repo_head_hexsha": "1846a919bd1ba337e8c3f161d7f95469cdd2d252", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/testcreatedelete.jl", "max_issues_repo_name": "tullytim/Pinecone.jl", "max_issues_repo_head_hexsha": "1846a919bd1ba337e8c3f161d7f95469cdd2d252", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/testcreatedelete.jl", "max_forks_repo_name": "tullytim/Pinecone.jl", "max_forks_repo_head_hexsha": "1846a919bd1ba337e8c3f161d7f95469cdd2d252", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.8, "max_line_length": 197, "alphanum_fraction": 0.719160105, "num_tokens": 618}
|
import pytest
import numpy as np
from context import Runner, ExecutionType, get_configs, docker_available
class MockContext():
def __init__(self):
self.obj = {}
@pytest.mark.skipif(not docker_available(), reason='Docker is not available')
def test_runner_langermann():
internal_conf = get_configs('csaopt/internal/csaopt-internal.conf')
ctx = {}
ctx['internal_conf'] = internal_conf
runner = Runner(['examples/ackley/ackley_opt.py'], ['examples/ackley/ackley.conf'], ctx)
runner.run()
if len(runner.failures) > 0:
raise Exception('Runner had failures: %s' % runner.failures)
assert runner.best_value == pytest.approx(0, abs=0.2)
|
{"hexsha": "efbcd20984caeb62b715ba75dbe7a42ac7515b65", "size": 685, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/test_runner.py", "max_stars_repo_name": "d53dave/cgopt", "max_stars_repo_head_hexsha": "a655d87a8577d18a7a714431f4237e4c9ebbf7e8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-08-11T18:58:16.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-11T18:58:16.000Z", "max_issues_repo_path": "tests/test_runner.py", "max_issues_repo_name": "d53dave/cgopt", "max_issues_repo_head_hexsha": "a655d87a8577d18a7a714431f4237e4c9ebbf7e8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2018-03-07T19:54:44.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-07T19:54:44.000Z", "max_forks_repo_path": "tests/test_runner.py", "max_forks_repo_name": "d53dave/cgopt", "max_forks_repo_head_hexsha": "a655d87a8577d18a7a714431f4237e4c9ebbf7e8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-01-10T19:30:10.000Z", "max_forks_repo_forks_event_max_datetime": "2018-01-10T19:30:10.000Z", "avg_line_length": 27.4, "max_line_length": 92, "alphanum_fraction": 0.703649635, "include": true, "reason": "import numpy", "num_tokens": 170}
|
# -*- coding: utf-8 -*-
from distutils.version import LooseVersion
import numpy
from aiida.orm import Dict, TrajectoryData
from qe_tools import CONSTANTS
from .base import Parser
from .parse_raw.cp import parse_cp_raw_output, parse_cp_traj_stanzas
class CpParser(Parser):
"""This class is the implementation of the Parser class for Cp."""
def parse(self, **kwargs):
"""Receives in input a dictionary of retrieved nodes.
Does all the logic here.
"""
retrieved = self.retrieved
# check what is inside the folder
list_of_files = retrieved._repository.list_object_names()
# options.metadata become attributes like this:
stdout_filename = self.node.get_attribute('output_filename')
# at least the stdout should exist
if stdout_filename not in list_of_files:
return self.exit(self.exit_codes.ERROR_OUTPUT_STDOUT_READ)
# This should match 1 file
xml_files = [xml_file for xml_file in self.node.process_class.xml_filenames if xml_file in list_of_files]
if not xml_files:
return self.exit(self.exit_codes.ERROR_MISSING_XML_FILE)
elif len(xml_files) > 1:
return self.exit(self.exit_codes.ERROR_OUTPUT_XML_MULTIPLE)
# cp.x can produce, depending on the particular version of the code, a file called `print_counter.xml` or
# `print_counter`, which is a plain text file with the number of the last timestep written in the trajectory
# output. Note that if no trajectory is produced (for example because a single conjugate gradient step was
# performed to calculate the ground state and the wavefunctions velocities) no printer_counter* file is written.
print_counter_xml = True
no_trajectory_output = False
filename_counter_txt = self.node.process_class._FILE_PRINT_COUNTER_BASENAME
filename_counter_xml = self.node.process_class._FILE_XML_PRINT_COUNTER_BASENAME
# The following can happen and is not an error!
if filename_counter_xml not in list_of_files and filename_counter_txt not in list_of_files:
self.logger.error(
f'We could not find the print counter file (`{filename_counter_txt}` or `{filename_counter_xml}`), '
'assuming no trajectory output was produced'
)
no_trajectory_output = True
if not no_trajectory_output:
if filename_counter_txt in list_of_files:
self.logger.info('print counter not in xml format')
print_counter_xml = False
filename_counter = filename_counter_txt
else: # xml format
print_counter_xml = True
self.logger.info('print counter in xml format')
filename_counter = filename_counter_xml
output_stdout = retrieved.get_object_content(stdout_filename)
output_xml = retrieved.get_object_content(xml_files[0])
output_xml_counter = None if no_trajectory_output else retrieved.get_object_content(filename_counter)
out_dict, _raw_successful = parse_cp_raw_output(
output_stdout, output_xml, output_xml_counter, print_counter_xml
)
if not no_trajectory_output:
# parse the trajectory. Units in Angstrom, picoseconds and eV.
# append everthing in the temporary dictionary raw_trajectory
raw_trajectory = {}
evp_keys = [
'electronic_kinetic_energy', 'cell_temperature', 'ionic_temperature', 'scf_total_energy', 'enthalpy',
'enthalpy_plus_kinetic', 'energy_constant_motion', 'volume', 'pressure'
]
# order of atom in the output trajectory changed somewhere after 6.5
if LooseVersion(out_dict['creator_version']) > LooseVersion('6.5'):
new_cp_ordering = True
else:
new_cp_ordering = False
# Now prepare the reordering, as files in the xml are ordered
if new_cp_ordering:
reordering = None
else:
try:
# this works for old xml only
reordering = self._generate_sites_ordering(out_dict['species'], out_dict['atoms'])
except KeyError:
# this works for newer versions
reordering = self._generate_sites_ordering(
out_dict['structure']['species'], out_dict['structure']['atoms']
)
pos_filename = f'{self.node.process_class._PREFIX}.pos'
if pos_filename not in list_of_files:
out_dict['warnings'].append('Unable to open the POS file... skipping.')
return self.exit_codes.ERROR_READING_POS_FILE
number_of_atoms = out_dict.get(
'number_of_atoms', out_dict['structure']['number_of_atoms'] if 'structure' in out_dict else None
)
trajectories = [
('positions', 'pos', CONSTANTS.bohr_to_ang, number_of_atoms),
('cells', 'cel', CONSTANTS.bohr_to_ang, 3),
('velocities', 'vel', CONSTANTS.bohr_to_ang / (CONSTANTS.timeau_to_sec * 10**12), number_of_atoms),
('forces', 'for', CONSTANTS.hartree_to_ev / CONSTANTS.bohr_to_ang, number_of_atoms),
]
for name, extension, scale, elements in trajectories:
try:
with retrieved.open(f'{self.node.process_class._PREFIX}.{extension}') as datafile:
data = [l.split() for l in datafile]
# POSITIONS stored in angstrom
traj_data = parse_cp_traj_stanzas(
num_elements=elements, splitlines=data, prepend_name=f'{name}_traj', rescale=scale
)
# here initialize the dictionary. If the parsing of positions fails, though, I don't have anything
# out of the CP dynamics. Therefore, the calculation status is set to FAILED.
if extension != 'cel':
raw_trajectory[f'{name}_ordered'] = self._get_reordered_array(
traj_data[f'{name}_traj_data'], reordering
)
else:
# NOTE: the trajectory output has the cell matrix transposed!!
raw_trajectory['cells'] = numpy.array(traj_data['cells_traj_data']).transpose((0, 2, 1))
if extension == 'pos':
raw_trajectory['traj_times'] = numpy.array(traj_data[f'{name}_traj_times'])
except IOError:
out_dict['warnings'].append(f'Unable to open the {extension.upper()} file... skipping.')
# =============== EVP trajectory ============================
try:
with retrieved.open(f'{self._node.process_class._PREFIX}.evp') as handle:
matrix = numpy.genfromtxt(handle)
# there might be a different format if the matrix has one row only
try:
matrix.shape[1]
except IndexError:
matrix = numpy.array(numpy.matrix(matrix))
if LooseVersion(out_dict['creator_version']) > LooseVersion('5.1'):
# Between version 5.1 and 5.1.1, someone decided to change
# the .evp output format, without any way to know that this
# happened... SVN commit 11158.
# I here use the version number to parse, plus some
# heuristics to check that I'm doing the right thing
#print "New version"
raw_trajectory['steps'] = numpy.array(matrix[:, 0], dtype=int)
raw_trajectory['times'] = matrix[:, 1] # TPS, ps
raw_trajectory['electronic_kinetic_energy'] = matrix[:, 2] * CONSTANTS.hartree_to_ev # EKINC, eV
raw_trajectory['cell_temperature'] = matrix[:, 3] # TEMPH, K
raw_trajectory['ionic_temperature'] = matrix[:, 4] # TEMPP, K
raw_trajectory['scf_total_energy'] = matrix[:, 5] * CONSTANTS.hartree_to_ev # ETOT, eV
raw_trajectory['enthalpy'] = matrix[:, 6] * CONSTANTS.hartree_to_ev # ENTHAL, eV
raw_trajectory['enthalpy_plus_kinetic'] = matrix[:, 7] * CONSTANTS.hartree_to_ev # ECONS, eV
raw_trajectory['energy_constant_motion'] = matrix[:, 8] * CONSTANTS.hartree_to_ev # ECONT, eV
raw_trajectory['volume'] = matrix[:, 9] * (CONSTANTS.bohr_to_ang**3) # volume, angstrom^3
raw_trajectory['pressure'] = matrix[:, 10] # out_press, GPa
else:
#print "Old version"
raw_trajectory['steps'] = numpy.array(matrix[:, 0], dtype=int)
raw_trajectory['electronic_kinetic_energy'] = matrix[:, 1] * CONSTANTS.hartree_to_ev # EKINC, eV
raw_trajectory['cell_temperature'] = matrix[:, 2] # TEMPH, K
raw_trajectory['ionic_temperature'] = matrix[:, 3] # TEMPP, K
raw_trajectory['scf_total_energy'] = matrix[:, 4] * CONSTANTS.hartree_to_ev # ETOT, eV
raw_trajectory['enthalpy'] = matrix[:, 5] * CONSTANTS.hartree_to_ev # ENTHAL, eV
raw_trajectory['enthalpy_plus_kinetic'] = matrix[:, 6] * CONSTANTS.hartree_to_ev # ECONS, eV
raw_trajectory['energy_constant_motion'] = matrix[:, 7] * CONSTANTS.hartree_to_ev # ECONT, eV
raw_trajectory['volume'] = matrix[:, 8] * (CONSTANTS.bohr_to_ang**3) # volume, angstrom^3
raw_trajectory['pressure'] = matrix[:, 9] # out_press, GPa
raw_trajectory['times'] = matrix[:, 10] # TPS, ps
# Huristics to understand if it's correct.
# A better heuristics could also try to fix possible issues
# (in new versions of QE, it's possible to recompile it with
# the __OLD_FORMAT flag to get back the old version format...)
# but I won't do it, as there may be also other columns swapped.
# Better to stop and ask the user to check what's going on.
#work around for 100ps format bug
mask = numpy.array(raw_trajectory['traj_times']) >= 0
len_bugged = len(numpy.array(raw_trajectory['times'])[mask == False])
len_ok = len(numpy.array(raw_trajectory['times'])[mask])
if len_ok > 0:
max_time_difference = abs(
numpy.array(raw_trajectory['times'])[mask] - numpy.array(raw_trajectory['traj_times'])[mask]
).max()
else:
max_time_difference = 0.0
if max_time_difference > 1.e-4 or (
len_bugged > 0 and numpy.array(raw_trajectory['times'])[mask == False].min() < 100.0
): # It is typically ~1.e-7 due to roundoff errors
# If there is a large discrepancy
# it means there is something very weird going on...
return self.exit_codes.ERROR_READING_TRAJECTORY_DATA
# keep both times array (that usually are duplicated)
# so that the user can check them by himselves
if len_bugged > 0:
out_dict['warnings'].append(
'100ps format bug detected: ignoring trajectory\'s printed time from 100ps on'
)
except IOError:
out_dict['warnings'].append('Unable to open the EVP file... skipping.')
# get the symbols from the input
# TODO: I should have kinds in TrajectoryData
input_structure = self.node.inputs.structure
raw_trajectory['symbols'] = [str(i.kind_name) for i in input_structure.sites]
traj = TrajectoryData()
traj.set_trajectory(
stepids=raw_trajectory['steps'],
cells=raw_trajectory['cells'],
symbols=raw_trajectory['symbols'],
positions=raw_trajectory['positions_ordered'],
times=raw_trajectory['times'],
velocities=raw_trajectory['velocities_ordered'],
)
# eventually set the forces
try:
traj.set_array('forces', raw_trajectory['forces_ordered'])
except KeyError:
out_dict['warnings'].append('failed to set forces')
for this_name in evp_keys:
try:
traj.set_array(this_name, raw_trajectory[this_name])
except KeyError:
# Some columns may have not been parsed, skip
pass
self.out('output_trajectory', traj)
# Remove big dictionaries that would be redundant
# For atoms and cell, there is a small possibility that nothing is parsed but then probably nothing moved.
for key in [
'atoms', 'cell', 'ions_positions_stau', 'ions_positions_svel', 'ions_positions_taui', 'atoms_index_list',
'atoms_if_pos_list', 'ions_positions_force', 'bands', 'structure'
]:
out_dict.pop(key, None)
# convert the dictionary into an AiiDA object
output_params = Dict(dict=out_dict)
self.out('output_parameters', output_params)
def get_linkname_trajectory(self):
"""Returns the name of the link to the output_structure (None if not present)"""
return 'output_trajectory'
def _generate_sites_ordering(self, raw_species, raw_atoms):
"""take the positions of xml and from file.pos of the LAST step and compare them."""
# Examples in the comments are for species [Ba, O, Ti]
# and atoms [Ba, Ti, O, O, O]
# Dictionary to associate the species name to the idx
# Example: {'Ba': 1, 'O': 2, 'Ti': 3}
species_dict = {name: idx for idx, name in zip(raw_species['index'], raw_species['type'])}
# List of the indices of the specie associated to each atom,
# in the order specified in input
# Example: (1,3,2,2,2)
atoms_species_idx = [species_dict[a[0]] for a in raw_atoms]
# I also attach the current position; important to convert to a list
# Otherwise the iterator can be looped on only once!
# Example: ((0,1),(1,3),(2,2),(3,2),(4,2))
ref_atom_list = list(enumerate(atoms_species_idx))
new_order_tmp = []
# I reorder the atoms, first by specie, then in their order
# This is the order used in output by CP!!
# Example: ((0,1),(2,2),(3,2),(4,2),(1,3))
for specie_idx in sorted(raw_species['index']):
for elem in ref_atom_list:
if elem[1] == specie_idx:
new_order_tmp.append(elem)
# This is the new order that is printed in CP:
# e.g. reordering[2] is the index of the atom, in the input
# list of atoms, that is printed in position 2 (0-based, so the
# third atom) in the CP output files.
# Example: [0,2,3,4,1]
reordering = [_[0] for _ in new_order_tmp]
# I now need the inverse reordering, to put back in place
# from the output ordering to the input one!
# Example: [0,4,1,2,3]
# Because in the final list (Ba, O, O, O, Ti)
# the first atom Ba in the input is atom 0 in the CP output (the first),
# the second atom Ti in the input is atom 4 (the fifth) in the CP output,
# and so on
sorted_indexed_reordering = sorted([(_[1], _[0]) for _ in enumerate(reordering)])
reordering_inverse = [_[1] for _ in sorted_indexed_reordering]
return reordering_inverse
def _get_reordered_list(self, origlist, reordering):
"""Given a list to reorder, a list of integer positions with the new order, return the reordered list."""
return [origlist[e] for e in reordering]
def _get_reordered_array(self, _input, reordering):
if reordering is not None:
return numpy.array([self._get_reordered_list(i, reordering) for i in _input])
else:
return numpy.array(_input)
|
{"hexsha": "143030d7b7b4c832b03c3fdc365597fe2ddd2f5f", "size": 16514, "ext": "py", "lang": "Python", "max_stars_repo_path": "aiida_quantumespresso/parsers/cp.py", "max_stars_repo_name": "ramirezfranciscof/aiida-quantumespresso", "max_stars_repo_head_hexsha": "cb32be5361afa05bad617f00f8b187c96eb365ec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2017-09-25T20:22:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T02:53:41.000Z", "max_issues_repo_path": "aiida_quantumespresso/parsers/cp.py", "max_issues_repo_name": "ramirezfranciscof/aiida-quantumespresso", "max_issues_repo_head_hexsha": "cb32be5361afa05bad617f00f8b187c96eb365ec", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 594, "max_issues_repo_issues_event_min_datetime": "2017-08-08T17:28:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T13:38:10.000Z", "max_forks_repo_path": "aiida_quantumespresso/parsers/cp.py", "max_forks_repo_name": "ramirezfranciscof/aiida-quantumespresso", "max_forks_repo_head_hexsha": "cb32be5361afa05bad617f00f8b187c96eb365ec", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 66, "max_forks_repo_forks_event_min_datetime": "2017-08-08T16:58:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T10:18:43.000Z", "avg_line_length": 53.2709677419, "max_line_length": 120, "alphanum_fraction": 0.5930725445, "include": true, "reason": "import numpy", "num_tokens": 3551}
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module provides tools for calculating total error arrays.
"""
import astropy.units as u
from astropy.utils.misc import isiterable
import numpy as np
__all__ = ['calc_total_error']
def calc_total_error(data, bkg_error, effective_gain):
"""
Calculate a total error array, combining a background-only error
array with the Poisson noise of sources.
Parameters
----------
data : array_like or `~astropy.units.Quantity`
The background-subtracted data array.
bkg_error : array_like or `~astropy.units.Quantity`
The 1-sigma background-only errors of the input ``data``.
``bkg_error`` should include all sources of "background" error
but *exclude* the Poisson error of the sources. ``bkg_error``
must have the same shape as ``data``. If ``data`` and
``bkg_error`` are `~astropy.units.Quantity` objects, then they
must have the same units.
effective_gain : float, array-like, or `~astropy.units.Quantity`
Ratio of counts (e.g., electrons or photons) to the units of
``data`` used to calculate the Poisson error of the sources. If
``effective_gain`` is zero (or contains zero values in an
array), then the source Poisson noise component will not be
included. In other words, the returned total error value will
simply be the ``bkg_error`` value for pixels where
``effective_gain`` is zero. ``effective_gain`` cannot not be
negative or contain negative values.
Returns
-------
total_error : `~numpy.ndarray` or `~astropy.units.Quantity`
The total error array. If ``data``, ``bkg_error``, and
``effective_gain`` are all `~astropy.units.Quantity` objects,
then ``total_error`` will also be returned as a
`~astropy.units.Quantity` object with the same units as the
input ``data``. Otherwise, a `~numpy.ndarray` will be returned.
Notes
-----
To use units, ``data``, ``bkg_error``, and ``effective_gain`` must
*all* be `~astropy.units.Quantity` objects. ``data`` and
``bkg_error`` must have the same units. A `ValueError` will be
raised if only some of the inputs are `~astropy.units.Quantity`
objects or if the ``data`` and ``bkg_error`` units differ.
The source Poisson error in countable units (e.g., electrons or
photons) is:
.. math::
\\sigma_{\\mathrm{src}} = \\sqrt{g_{\\mathrm{eff}} I}
where :math:`g_{\\mathrm{eff}}` is the effective gain
(``effective_gain``; image or scalar) and :math:`I` is the ``data``
image.
The total error is the combination of the background-only error and
the source Poisson error. The total error array
:math:`\\sigma_{\\mathrm{tot}}` in countable units (e.g., electrons
or photons) is therefore:
.. math::
\\sigma_{\\mathrm{tot}} = \\sqrt{g_{\\mathrm{eff}}^2
\\sigma_{\\mathrm{bkg}}^2 + g_{\\mathrm{eff}} I}
where :math:`\\sigma_{\\mathrm{bkg}}` is the background-only error
image (``bkg_error``).
Converting back to the input ``data`` units gives:
.. math::
\\sigma_{\\mathrm{tot}} = \\frac{1}{g_{\\mathrm{eff}}}
\\sqrt{g_{\\mathrm{eff}}^2
\\sigma_{\\mathrm{bkg}}^2 + g_{\\mathrm{eff}} I}
.. math::
\\sigma_{\\mathrm{tot}} = \\sqrt{\\sigma_{\\mathrm{bkg}}^2 +
\\frac{I}{g_{\\mathrm{eff}}}}
``effective_gain`` can either be a scalar value or a 2D image with
the same shape as the ``data``. A 2D ``effective_gain`` image is
useful when the input ``data`` has variable depths across the field
(e.g., a mosaic image with non-uniform exposure times). For
example, if your input ``data`` are in units of electrons/s then
ideally ``effective_gain`` should be an exposure-time map.
The Poisson noise component is not included in the output total
error for pixels where ``data`` (:math:`I_i)` is negative. For such
pixels, :math:`\\sigma_{\\mathrm{tot}, i} = \\sigma_{\\mathrm{bkg},
i}`.
The Poisson noise component is also not included in the output total
error for pixels where the effective gain (:math:`g_{\\mathrm{eff},
i}`) is zero. For such pixels, :math:`\\sigma_{\\mathrm{tot}, i} =
\\sigma_{\\mathrm{bkg}, i}`.
To replicate `SExtractor`_ errors when it is configured to consider
weight maps as gain maps (i.e. 'WEIGHT_GAIN=Y'; which is the
default), one should input an ``effective_gain`` calculated as:
.. math:: g_{\\mathrm{eff}}^{\\prime} = g_{\\mathrm{eff}} \\left(
\\frac{\\mathrm{RMS_{\\mathrm{median}}^2}}{\\sigma_{\\mathrm{bkg}}^2} \\right)
where :math:`g_{\\mathrm{eff}}` is the effective gain,
:math:`\\sigma_{\\mathrm{bkg}}` are the background-only errors, and
:math:`\\mathrm{RMS_{\\mathrm{median}}}` is the median value of the
low-resolution background RMS map generated by `SExtractor`_. When
running `SExtractor`_, this value is printed to stdout as "(M+D)
RMS: <value>". If you are using
`~photutils.background.Background2D`, the median value of the
low-resolution background RMS map is returned via the
`~photutils.background.Background2D.background_rms_median`
attribute.
In that case the total error is:
.. math:: \\sigma_{\\mathrm{tot}} = \\sqrt{\\sigma_{\\mathrm{bkg}}^2 +
\\left(\\frac{I}{g_{\\mathrm{eff}}}\\right)
\\left(\\frac{\\sigma_{\\mathrm{bkg}}^2}
{\\mathrm{RMS_{\\mathrm{median}}^2}}\\right)}
.. _SExtractor: https://www.astromatic.net/software/sextractor
"""
data = np.asanyarray(data)
bkg_error = np.asanyarray(bkg_error)
inputs = [data, bkg_error, effective_gain]
has_unit = [hasattr(x, 'unit') for x in inputs]
use_units = all(has_unit)
if any(has_unit) and not use_units:
raise ValueError('If any of data, bkg_error, or effective_gain has '
'units, then they all must all have units.')
if use_units:
if data.unit != bkg_error.unit:
raise ValueError('data and bkg_error must have the same units.')
count_units = [u.electron, u.photon]
datagain_unit = data.unit * effective_gain.unit
if datagain_unit not in count_units:
raise u.UnitsError('(data * effective_gain) has units of "{0}", '
'but it must have count units (e.g. '
'u.electron or u.photon).'
.format(datagain_unit))
if not isiterable(effective_gain):
effective_gain = np.zeros(data.shape) + effective_gain
else:
effective_gain = np.asanyarray(effective_gain)
if effective_gain.shape != data.shape:
raise ValueError('If input effective_gain is 2D, then it must '
'have the same shape as the input data.')
if np.any(effective_gain < 0):
raise ValueError('effective_gain must be non-zero everywhere.')
if use_units:
unit = data.unit
data = data.value
effective_gain = effective_gain.value
# do not include source variance where effective_gain = 0
source_variance = np.where(effective_gain != 0, data / effective_gain, 0)
# do not include source variance where data is negative (note that
# effective_gain cannot be negative)
source_variance = np.maximum(source_variance, 0)
if use_units:
# source_variance is calculated to have units of (data.unit)**2
# so that it can be added with bkg_error**2 below. The returned
# total error will have units of data.unit.
source_variance <<= unit**2
return np.sqrt(bkg_error**2 + source_variance)
|
{"hexsha": "67e969f13b71b077283c91eeb3346832c2d32774", "size": 7791, "ext": "py", "lang": "Python", "max_stars_repo_path": "photutils/utils/errors.py", "max_stars_repo_name": "pllim/photutils", "max_stars_repo_head_hexsha": "ff78b6dd97a9fa890b6c77b51f207d4c2ff28889", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "photutils/utils/errors.py", "max_issues_repo_name": "pllim/photutils", "max_issues_repo_head_hexsha": "ff78b6dd97a9fa890b6c77b51f207d4c2ff28889", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "photutils/utils/errors.py", "max_forks_repo_name": "pllim/photutils", "max_forks_repo_head_hexsha": "ff78b6dd97a9fa890b6c77b51f207d4c2ff28889", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6631016043, "max_line_length": 85, "alphanum_fraction": 0.6385573097, "include": true, "reason": "import numpy,import astropy,from astropy", "num_tokens": 2020}
|
[STATEMENT]
lemma up_injective:
"\<up>x = \<up>y \<Longrightarrow> x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<up>x = \<up>y \<Longrightarrow> x = y
[PROOF STEP]
using order.antisym
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?a \<le> ?b; ?b \<le> ?a\<rbrakk> \<Longrightarrow> ?a = ?b
goal (1 subgoal):
1. \<up>x = \<up>y \<Longrightarrow> x = y
[PROOF STEP]
by auto
|
{"llama_tokens": 172, "file": "Stone_Algebras_Filters", "length": 2}
|
"""
check https://github.com/thautwarm/MLStyle.jl/blob/master/matrix_benchmark.jl
"""
include("matrix-benchmark/sampler.jl")
include("matrix-benchmark/utils.jl")
export ArbitrarySampler
export Utils
versus_items = ("datatype", "misc", "tuple", "array", "structfields", "vs-match")
function run_all()
for item in versus_items
run_one(item)
end
end
function run_one(item)
filename = "matrix-benchmark/bench-$item.jl"
open(filename) do f
include_string(Main, read(f, String), filename)
end
end
|
{"hexsha": "bed74abf1a55f53e09cf9b9fff5ceb6ab1e73c12", "size": 531, "ext": "jl", "lang": "Julia", "max_stars_repo_path": "benchmark.jl", "max_stars_repo_name": "caseykneale/MLStyle.jl", "max_stars_repo_head_hexsha": "866e3bf3fcd21329bdc8cf3bd0d8d576fe33b666", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 309, "max_stars_repo_stars_event_min_datetime": "2018-08-13T01:05:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T13:14:46.000Z", "max_issues_repo_path": "benchmark.jl", "max_issues_repo_name": "caseykneale/MLStyle.jl", "max_issues_repo_head_hexsha": "866e3bf3fcd21329bdc8cf3bd0d8d576fe33b666", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 131, "max_issues_repo_issues_event_min_datetime": "2018-08-14T05:15:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-01T09:51:53.000Z", "max_forks_repo_path": "benchmark.jl", "max_forks_repo_name": "caseykneale/MLStyle.jl", "max_forks_repo_head_hexsha": "866e3bf3fcd21329bdc8cf3bd0d8d576fe33b666", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 33, "max_forks_repo_forks_event_min_datetime": "2018-08-14T04:41:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T13:37:16.000Z", "avg_line_length": 22.125, "max_line_length": 81, "alphanum_fraction": 0.7062146893, "num_tokens": 138}
|
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Unit tests for KinwaveImplicitOverlandFlowModel.
Created on Sat Apr 1 10:49:33 2017
@author: gtucker
"""
from numpy.testing import assert_allclose, assert_raises
from landlab import RasterModelGrid
from landlab.components import LinearDiffusionOverlandFlowRouter
def test_steady_one_node():
"""Run to steady state with a single node"""
xy_spacing = 2.0
roughness = 0.01
velocity_scale = 1.0
rain_rate = 72.0 / (3600.0 * 1000.0)
grid = RasterModelGrid((3, 3), xy_spacing=xy_spacing)
grid.set_closed_boundaries_at_grid_edges(False, True, True, True)
grid.add_zeros("topographic__elevation", at="node")
olflow = LinearDiffusionOverlandFlowRouter(
grid, rain_rate=rain_rate, roughness=roughness, velocity_scale=velocity_scale
)
for _ in range(18):
olflow.run_one_step(20.0)
actual = grid.at_node["surface_water__depth"][4]
expected = (grid.dx * grid.dy * olflow.rain_rate / olflow.vel_coef) ** 0.3
assert_allclose(actual, expected, atol=1e-4)
def test_invalid_parameters():
"""Make sure invalid parameters raise the right exceptions."""
grid = RasterModelGrid((3, 3))
grid.add_zeros("topographic__elevation", at="node")
assert_raises(ValueError, LinearDiffusionOverlandFlowRouter, grid, roughness=-1.0)
assert_raises(ValueError, LinearDiffusionOverlandFlowRouter, grid, rain_rate=-1.0)
assert_raises(
ValueError, LinearDiffusionOverlandFlowRouter, grid, infilt_depth_scale=0.0
)
assert_raises(ValueError, LinearDiffusionOverlandFlowRouter, grid, infilt_rate=-1.0)
assert_raises(
ValueError, LinearDiffusionOverlandFlowRouter, grid, velocity_scale=0.0
)
assert_raises(ValueError, LinearDiffusionOverlandFlowRouter, grid, cfl_factor=0.0)
assert_raises(ValueError, LinearDiffusionOverlandFlowRouter, grid, cfl_factor=2.0)
olflow = LinearDiffusionOverlandFlowRouter(grid)
try:
olflow.rain_rate = -1.0
except ValueError:
pass
else:
raise AssertionError("Setting negative rain_rate should raise ValueError")
|
{"hexsha": "f8a4616e592559a9ac6ff3141c3be3df862a44ba", "size": 2136, "ext": "py", "lang": "Python", "max_stars_repo_path": "tests/components/overland_flow/test_linear_diffusion_overland_flow.py", "max_stars_repo_name": "clebouteiller/landlab", "max_stars_repo_head_hexsha": "e6f47db76ea0814c4c5a24e695bbafb74c722ff7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-07T02:36:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T02:36:07.000Z", "max_issues_repo_path": "tests/components/overland_flow/test_linear_diffusion_overland_flow.py", "max_issues_repo_name": "clebouteiller/landlab", "max_issues_repo_head_hexsha": "e6f47db76ea0814c4c5a24e695bbafb74c722ff7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-11T21:23:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T21:23:46.000Z", "max_forks_repo_path": "tests/components/overland_flow/test_linear_diffusion_overland_flow.py", "max_forks_repo_name": "clebouteiller/landlab", "max_forks_repo_head_hexsha": "e6f47db76ea0814c4c5a24e695bbafb74c722ff7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-08-19T08:58:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T02:36:01.000Z", "avg_line_length": 35.6, "max_line_length": 88, "alphanum_fraction": 0.736423221, "include": true, "reason": "from numpy", "num_tokens": 572}
|
import logging
import uuid
import numpy as np
from sklearn.datasets import load_diabetes
import pandas as pd
import os
from commons.utils.singleton import Singleton
class Metadata:
id = None
filename = None
features = None
features_min = None
features_max = None
target_min = None
target_max = None
def __init__(self, filename, features, feature_values, target_values):
self.id = str(uuid.uuid1())
self.filename = filename
self.features = features
self.features_min = feature_values.min().min()
self.features_max = feature_values.max().min()
self.target_min = target_values.min()
self.target_max = target_values.max()
class DataLoader(metaclass=Singleton):
def __init__(self, dataset_path):
self.X, self.y, self.X_test, self.y_test = None, None, None, None
self.seed = 43
np.random.seed(self.seed)
self.dataset_path = dataset_path
def load_data(self, filename):
"""
Loads a dataset from the filesystem reading the file with name 'filename'.
The features are stored in self.X as an np.array
The target is stored in a self.y as an np.array
:param filename:
:return: None
"""
dataset = pd.read_csv("{}/{}".format(self.dataset_path, filename), sep='\t')
df_X = dataset[dataset.columns[:-1]]
# Add constant to emulate intercept
df_X[len(dataset.columns)] = 1
df_y = dataset[dataset.columns[-1]]
self.X = np.asarray(df_X.values.tolist())
self.y = np.asarray(df_y.values.tolist())
def load_data_deprecated(self, n_subsets):
"""
Import the dataset via sklearn, shuffle and split train/test.
Return training, target lists for `n_clients` and a holdout test set
"""
logging.info("Loading data")
diabetes = load_diabetes()
y = diabetes.target
X = diabetes.data
# Add constant to emulate intercept
X = np.c_[X, np.ones(X.shape[0])]
# The features are already preprocessed
# Shuffle
perm = np.random.permutation(X.shape[0])
X, y = X[perm, :], y[perm]
# Select test at random
test_size = 50
test_idx = np.random.choice(X.shape[0], size=test_size, replace=False)
train_idx = np.ones(X.shape[0], dtype=bool)
train_idx[test_idx] = False
X_test, y_test = X[test_idx, :], y[test_idx]
X_train, y_train = X[train_idx, :], y[train_idx]
# Split train among multiple clients.
# The selection is not at random. We simulate the fact that each client
# sees a potentially very different sample of patients.
X, y = {}, {}
step = int(X_train.shape[0] / n_subsets)
for c in range(n_subsets):
X[c] = X_train[step * c: step * (c + 1), :]
y[c] = y_train[step * c: step * (c + 1)]
self.X, self.y, self.X_test, self.y_test = X, y, X_test, y_test
def get_sub_set(self):
"""
Returns the dataset loaded by self.load_data(filename).
:return: a tuple self.X (np.array of features) and self.y (np.array of target)
"""
return self.X, self.y
def get_training_sub_set(self):
"""
Returns the dataset loaded by self.load_data(filename) for testing.
:return: a tuple self.X (np.array of features) and self.y (np.array of target)
"""
return self.X_test, self.y_test
@staticmethod
def load_random_data():
logging.info("Loading data")
diabetes = load_diabetes()
y = diabetes.target
X = diabetes.data
# Add constant to emulate intercept
X = np.c_[X, np.ones(X.shape[0])]
# The features are already preprocessed
# Shuffle
perm = np.random.permutation(X.shape[0])
X, y = X[perm, :], y[perm]
# Select test at random
test_size = 50
test_idx = np.random.choice(X.shape[0], size=test_size, replace=False)
train_idx = np.ones(X.shape[0], dtype=bool)
train_idx[test_idx] = False
X_test, y_test = X[test_idx, :], y[test_idx]
X_train, y_train = X[train_idx, :], y[train_idx]
return X_train, y_train, X_test, y_test
def get_dataset_for_training_deprecated(self, requeriments):
"""
Iterates over the files in the datasets directory and verifies wich of those comply with the requested
requirements for the current model training. The last of the datasets that complies with the requirements
is then returned by this method.
:param requeriments: a dictionary with requirements for the dataset to be returned
:return: the name of the file that complies with the requested requirements.
"""
files = [fname for fname in os.listdir(self.dataset_path)]
features = list(map(lambda x: x.lower(), requeriments['features']['list']))
feat_range = requeriments['features']['range']
target_range = requeriments['target']['range']
for file in files:
try:
dataset = pd.read_csv("{}/{}".format(self.dataset_path, file), sep="\t")
columns = dataset.columns.tolist()
feature_values = dataset[columns[:-1]]
target_values = dataset[columns[-1]]
lowercase_cols = list(map(lambda x: x.lower(), columns[:-1]))
if set(lowercase_cols) != set(features):
continue
if feature_values.max().max() > feat_range[1]:
continue
if feature_values.min().min() < feat_range[0]:
continue
if target_values.max() > target_range[1]:
continue
if target_values.min() < target_range[0]:
continue
except Exception as e:
logging.error(e)
continue
return file
def get_dataset_metadata(self, filename):
try:
dataset = pd.read_csv("{}/{}".format(self.dataset_path, filename), sep="\t")
columns = dataset.columns.tolist()
feature_values = dataset[columns[:-1]]
target_values = dataset[columns[-1]]
lowercase_cols = list(map(lambda x: x.lower(), columns[:-1]))
return Metadata(filename=filename,
features=lowercase_cols,
feature_values=feature_values,
target_values=target_values)
except Exception as e:
logging.error(e)
return None
|
{"hexsha": "755c2f37f3588d625a196b2711a03dcf726867a1", "size": 6699, "ext": "py", "lang": "Python", "max_stars_repo_path": "commons/data/data_loader.py", "max_stars_repo_name": "DeltaML/commons", "max_stars_repo_head_hexsha": "5f75783e8e63972bc906fac9f63eb4d1469cad4a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-24T02:19:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-24T02:19:18.000Z", "max_issues_repo_path": "commons/data/data_loader.py", "max_issues_repo_name": "DeltaML/commons", "max_issues_repo_head_hexsha": "5f75783e8e63972bc906fac9f63eb4d1469cad4a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-08-23T02:02:17.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-11T03:22:09.000Z", "max_forks_repo_path": "commons/data/data_loader.py", "max_forks_repo_name": "DeltaML/commons", "max_forks_repo_head_hexsha": "5f75783e8e63972bc906fac9f63eb4d1469cad4a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0625, "max_line_length": 113, "alphanum_fraction": 0.5936706971, "include": true, "reason": "import numpy", "num_tokens": 1473}
|
[STATEMENT]
lemma en_eq_3[PLM]:
"[\<^bold>\<diamond>\<lbrace>x,F\<rbrace> \<^bold>\<equiv> \<lbrace>x,F\<rbrace> in v]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. [\<^bold>\<diamond>\<lbrace>x,F\<rbrace> \<^bold>\<equiv> \<lbrace>x,F\<rbrace> in v]
[PROOF STEP]
using encoding[axiom_instance] derived_S5_rules_2_b "\<^bold>\<equiv>I" "T\<^bold>\<diamond>"
[PROOF STATE]
proof (prove)
using this:
[\<lbrace>?x1,?F1\<rbrace> \<^bold>\<rightarrow> \<^bold>\<box>\<lbrace>?x1,?F1\<rbrace> in ?v]
(\<And>v. [?\<phi> \<^bold>\<rightarrow> \<^bold>\<box>?\<psi> in v]) \<Longrightarrow> [\<^bold>\<diamond>?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v]
\<lbrakk>[?\<phi> \<^bold>\<rightarrow> ?\<psi> in ?v]; [?\<psi> \<^bold>\<rightarrow> ?\<phi> in ?v]\<rbrakk> \<Longrightarrow> [?\<phi> \<^bold>\<equiv> ?\<psi> in ?v]
[?\<phi> \<^bold>\<rightarrow> \<^bold>\<diamond>?\<phi> in ?v]
goal (1 subgoal):
1. [\<^bold>\<diamond>\<lbrace>x,F\<rbrace> \<^bold>\<equiv> \<lbrace>x,F\<rbrace> in v]
[PROOF STEP]
by auto
|
{"llama_tokens": 444, "file": "PLM_TAO_9_PLM", "length": 2}
|
[STATEMENT]
lemma alphaAbs_qAbs_imp_alphaAbs_all_qFresh:
assumes "qGood X" and "qAbs xs x X $= qAbs xs' x' X'"
shows "alphaAbs_all_qFresh xs x X xs' x' X'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
let ?Left = "(qAbs xs x X $= qAbs xs' x' X')"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
let ?Middle = "alphaAbs_all_equal_or_qFresh xs x X xs' x' X'"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
let ?Right = "alphaAbs_all_qFresh xs x X xs' x' X'"
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
have "?Left \<Longrightarrow> ?Middle"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
[PROOF STEP]
using assms alphaAbs_qAbs_imp_alphaAbs_all_equal_or_qFresh
[PROOF STATE]
proof (prove)
using this:
qGood X
qAbs xs x X $= qAbs xs' x' X'
\<lbrakk>qGood ?X; qAbs ?xs ?x ?X $= qAbs ?xs' ?x' ?X'\<rbrakk> \<Longrightarrow> alphaAbs_all_equal_or_qFresh ?xs ?x ?X ?xs' ?x' ?X'
goal (1 subgoal):
1. qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
have "?Middle \<Longrightarrow> ?Right"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. alphaAbs_all_equal_or_qFresh xs x X xs' x' X' \<Longrightarrow> alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
unfolding alphaAbs_all_equal_or_qFresh_def alphaAbs_all_qFresh_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. xs = xs' \<and> (\<forall>y. (y = x \<or> qFresh xs y X) \<and> (y = x' \<or> qFresh xs y X') \<longrightarrow> X #[[y \<and> x]]_xs #= X' #[[y \<and> x']]_xs) \<Longrightarrow> xs = xs' \<and> (\<forall>y. qFresh xs y X \<and> qFresh xs y X' \<longrightarrow> X #[[y \<and> x]]_xs #= X' #[[y \<and> x']]_xs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
alphaAbs_all_equal_or_qFresh xs x X xs' x' X' \<Longrightarrow> alphaAbs_all_qFresh xs x X xs' x' X'
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
alphaAbs_all_equal_or_qFresh xs x X xs' x' X' \<Longrightarrow> alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
alphaAbs_all_equal_or_qFresh xs x X xs' x' X' \<Longrightarrow> alphaAbs_all_qFresh xs x X xs' x' X'
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
qAbs xs x X $= qAbs xs' x' X' \<Longrightarrow> alphaAbs_all_equal_or_qFresh xs x X xs' x' X'
alphaAbs_all_equal_or_qFresh xs x X xs' x' X' \<Longrightarrow> alphaAbs_all_qFresh xs x X xs' x' X'
qGood X
qAbs xs x X $= qAbs xs' x' X'
goal (1 subgoal):
1. alphaAbs_all_qFresh xs x X xs' x' X'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
alphaAbs_all_qFresh xs x X xs' x' X'
goal:
No subgoals!
[PROOF STEP]
qed
|
{"llama_tokens": 1751, "file": "Binding_Syntax_Theory_QuasiTerms_PickFresh_Alpha", "length": 16}
|
MODULE wlGridModule
USE wlKindModule, ONLY: dp
IMPLICIT NONE
PRIVATE
TYPE, PUBLIC :: GridType
CHARACTER(LEN=32) :: Name
CHARACTER(LEN=32) :: Unit
INTEGER :: nPoints
INTEGER :: LogInterp
REAL(dp) :: minValue
REAL(dp) :: maxValue
REAL(dp), DIMENSION(:), ALLOCATABLE :: Values
END TYPE
PUBLIC :: MakeLinearGrid
PUBLIC :: MakeLogGrid
PUBLIC :: AllocateGrid
PUBLIC :: DeallocateGrid
PUBLIC :: DescribeGrid
CONTAINS
SUBROUTINE MakeLinearGrid( LowerBound, UpperBound, nPoints, Grid )
INTEGER, INTENT(in) :: nPoints
REAL(dp), INTENT(in) :: LowerBound
REAL(dp), INTENT(in) :: UpperBound
REAl(dp), DIMENSION(nPoints), INTENT(out) :: Grid
INTEGER :: i
REAL(dp) :: BinWidth
IF ( nPoints == 1 ) THEN
Grid(1) = LowerBound
RETURN
END IF
BinWidth = ( UpperBound - LowerBound ) / DBLE( nPoints - 1 )
DO i = 1, nPoints
Grid(i) = LowerBound + DBLE( i - 1 ) * BinWidth
END DO
END SUBROUTINE MakeLinearGrid
SUBROUTINE MakeLogGrid( LowerBound, UpperBound, nPoints, Grid )
Integer, INTENT(in) :: nPoints
REAL(dp), INTENT(in) :: LowerBound
Real(dp), INTENT(in) :: UpperBound
REAl(dp), DIMENSION(nPoints), INTENT(out) :: Grid
Integer :: m
REAL(dp) :: ScaleFactor
IF ( nPoints == 1 ) THEN
Grid(1) = LowerBound
RETURN
END IF
ScaleFactor &
= EXP( LOG( UpperBound / LowerBound ) / DBLE( nPoints - 1 ) )
Grid(1) = LowerBound
DO m = 2, nPoints - 1
Grid(m) = Grid(m-1) * ScaleFactor
END DO
Grid(nPoints) = UpperBound
END SUBROUTINE MakeLogGrid
SUBROUTINE AllocateGrid( Grid, nPoints )
TYPE(GridType), INTENT(inout) :: Grid
INTEGER, INTENT(in) :: nPoints
Grid % nPoints = nPoints
ALLOCATE( Grid % Values(nPoints) )
END SUBROUTINE AllocateGrid
SUBROUTINE DeAllocateGrid( Grid )
TYPE(GridType), INTENT(inout) :: Grid
DEALLOCATE( Grid % Values )
END SUBROUTINE DeAllocateGrid
SUBROUTINE DescribeGrid( Grid )
TYPE(GridType), INTENT(in) :: Grid
INTEGER :: i
WRITE(*,*)
WRITE(*,'(A4,A)') '', 'Grid:'
WRITE(*,*)
WRITE(*,'(A6,A12,A)') &
' ', 'Name = ', TRIM( Grid % Name )
WRITE(*,'(A6,A12,A)') &
' ', 'Unit = ', TRIM( Grid % Unit )
WRITE(*,'(A6,A12,ES10.3E2)') &
' ', 'Min Value = ', Grid % minValue
WRITE(*,'(A6,A12,ES10.3E2)') &
' ', 'Max Value = ', Grid % maxValue
WRITE(*,'(A6,A12,I4.4)') &
' ', 'nPoints = ', Grid % nPoints
IF ( Grid % LogInterp == 1 ) THEN
WRITE (*,'(A6,A27)') &
' ', 'Grid Logarithmically Spaced'
ELSE
WRITE (*,'(A6,A20)') &
' ', 'Grid Linearly Spaced'
END IF
WRITE(*,*)
DO i = 1, Grid % nPoints
WRITE(*,'(A8,A6,I4.4,A4,ES10.3E2)') &
' ','Value(', i, ') = ', Grid % Values(i)
END DO
END SUBROUTINE DescribeGrid
END MODULE wlGridModule
|
{"hexsha": "995c9f91777dc0034476b34a5c388a34e2c0bed9", "size": 3044, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Distributions/Library/wlGridModule.f90", "max_stars_repo_name": "srichers/weaklib", "max_stars_repo_head_hexsha": "4a26ff17d3224d8fe90b922cb55ea9d865200154", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T11:59:44.000Z", "max_issues_repo_path": "Distributions/Library/wlGridModule.f90", "max_issues_repo_name": "ranchu1/weaklib", "max_issues_repo_head_hexsha": "cfd3d600fef4dbd9789462270e0ef469878b2f53", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2020-07-13T22:42:06.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-23T19:08:53.000Z", "max_forks_repo_path": "Distributions/Library/wlGridModule.f90", "max_forks_repo_name": "ranchu1/weaklib", "max_forks_repo_head_hexsha": "cfd3d600fef4dbd9789462270e0ef469878b2f53", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2019-11-16T14:59:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-28T01:37:37.000Z", "avg_line_length": 22.3823529412, "max_line_length": 68, "alphanum_fraction": 0.5604467806, "num_tokens": 965}
|
#!/usr/bin/env python
import rospy
import numpy as np
from geometry_msgs.msg import Point
from std_msgs.msg import Int64
import time
import math
from Adafruit_MotorHAT import Adafruit_MotorHAT
class gazebo_car_control_node(object):
def __init__(self):
self.node_name = "gazebo_car_control_node"
self.active = True
self.i = 0
self.motorhat = Adafruit_MotorHAT(addr=0x60)
self.gazebo_car_control_L = self.motorhat.getMotor(1)
self.gazebo_car_control_R = self.motorhat.getMotor(2)
self.threshold = 0
self.sub_control_value = rospy.Subscriber("/gazebo_sub_jointstate/control_value", Point, self.cbControl_value, queue_size=1)
self.sub_threshold_value = rospy.Subscriber("/gazebo_sub_jointstate/threshold_value", Int64, self.cbThreshold_value, queue_size=1)
def cbThreshold_value(self, msg):
self.threshold = msg.data
def cbControl_value(self, msg):
u_R = int(msg.x)
u_L = int(msg.y)
print "u_R = ",u_R,"\tu_L = ",u_L
# if u_R > 200:
# u_R = 200
# if u_L > 200:
# u_L = 200
# if u_R < -200:
# u_R = -200
# if u_L < -200:
# u_L = -200
if u_R > self.threshold:
self.gazebo_car_control_R.setSpeed(u_R)
self.gazebo_car_control_R.run(Adafruit_MotorHAT.FORWARD)
elif u_R < -(self.threshold):
self.gazebo_car_control_R.setSpeed(-u_R)
self.gazebo_car_control_R.run(Adafruit_MotorHAT.BACKWARD)
else:
self.gazebo_car_control_R.setSpeed(0)
self.gazebo_car_control_R.run(Adafruit_MotorHAT.BACKWARD)
if u_L > self.threshold:
self.gazebo_car_control_L.setSpeed(u_L)
self.gazebo_car_control_L.run(Adafruit_MotorHAT.FORWARD)
elif u_L < -(self.threshold):
self.gazebo_car_control_L.setSpeed(-u_L)
self.gazebo_car_control_L.run(Adafruit_MotorHAT.BACKWARD)
else:
self.gazebo_car_control_L.setSpeed(0)
self.gazebo_car_control_L.run(Adafruit_MotorHAT.FORWARD)
# self.gazebo_car_control_.run(Adafruit_MotorHAT.RELEASE)
def onShutdown(self):
rospy.loginfo("[gazebo_car_control_node] Shutdown.")
if __name__ == '__main__':
rospy.init_node('gazebo_car_control_node',anonymous=False)
gazebo_car_control_node = gazebo_car_control_node()
rospy.on_shutdown(gazebo_car_control_node.onShutdown)
rospy.spin()
|
{"hexsha": "258a2d48560b1ec21f684475acb740739ffc103d", "size": 2229, "ext": "py", "lang": "Python", "max_stars_repo_path": "catkin_ws/src/arg_nctu/kaku/duckietown_kaku/src/gazebo_car_control_node.py", "max_stars_repo_name": "eric565648/duckietown-pi2", "max_stars_repo_head_hexsha": "33af7985a857a323e15d20e6572bc07530a16aea", "max_stars_repo_licenses": ["CC-BY-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-12T14:06:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-12T14:06:06.000Z", "max_issues_repo_path": "catkin_ws/src/arg_nctu/kaku/duckietown_kaku/src/gazebo_car_control_node.py", "max_issues_repo_name": "championway/DuckietownPi3_NCTU", "max_issues_repo_head_hexsha": "ab80ec901ab50337b5f20c9652bc7b8503e2a348", "max_issues_repo_licenses": ["CC-BY-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "catkin_ws/src/arg_nctu/kaku/duckietown_kaku/src/gazebo_car_control_node.py", "max_forks_repo_name": "championway/DuckietownPi3_NCTU", "max_forks_repo_head_hexsha": "ab80ec901ab50337b5f20c9652bc7b8503e2a348", "max_forks_repo_licenses": ["CC-BY-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5342465753, "max_line_length": 132, "alphanum_fraction": 0.7501121579, "include": true, "reason": "import numpy", "num_tokens": 691}
|
import os.path as osp
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms
import os
import numpy as np
class MiniImageNet(Dataset):
def __init__(self, setname, args, return_path=False):
IMAGE_PATH = os.path.join(args.data_dir, 'miniimagenet/images')
SPLIT_PATH = os.path.join(args.data_dir, 'miniimagenet/split')
csv_path = osp.join(SPLIT_PATH, setname + '.csv')
lines = [x.strip() for x in open(csv_path, 'r').readlines()][1:]
data = []
label = []
lb = -1
self.wnids = []
self.args = args
for l in lines:
name, wnid = l.split(',')
path = osp.join(IMAGE_PATH, name)
if wnid not in self.wnids:
self.wnids.append(wnid)
lb += 1
data.append(path)
label.append(lb)
self.data = data # data path of all data
self.label = label # label of all data
self.num_class = len(set(label))
self.return_path = return_path
if setname == 'val' or setname == 'test':
image_size = 84
resize_size = 92
self.transform = transforms.Compose([
transforms.Resize([resize_size, resize_size]),
transforms.CenterCrop(image_size),
transforms.ToTensor(),
transforms.Normalize(np.array([x / 255.0 for x in [125.3, 123.0, 113.9]]),
np.array([x / 255.0 for x in [63.0, 62.1, 66.7]]))])
elif setname == 'train':
image_size = 84
self.transform = transforms.Compose([
transforms.RandomResizedCrop(image_size),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize(np.array([x / 255.0 for x in [125.3, 123.0, 113.9]]),
np.array([x / 255.0 for x in [63.0, 62.1, 66.7]]))])
def __len__(self):
return len(self.data)
def __getitem__(self, i):
path, label = self.data[i], self.label[i]
image = self.transform(Image.open(path).convert('RGB'))
if self.return_path:
return image, label, path
else:
return image, label
if __name__ == '__main__':
pass
|
{"hexsha": "8ab819d07f24d03a67d3ed1fcde2941dffd6b502", "size": 2349, "ext": "py", "lang": "Python", "max_stars_repo_path": "models/dataloader/mini_imagenet.py", "max_stars_repo_name": "TJUdyk/Matrix_RENet", "max_stars_repo_head_hexsha": "5d066e4e08e412b1f880c63743edfdb72bdc7138", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 50, "max_stars_repo_stars_event_min_datetime": "2021-08-18T23:41:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T03:08:40.000Z", "max_issues_repo_path": "models/dataloader/mini_imagenet.py", "max_issues_repo_name": "TJUdyk/renet", "max_issues_repo_head_hexsha": "5d066e4e08e412b1f880c63743edfdb72bdc7138", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2021-08-31T11:55:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T02:16:27.000Z", "max_forks_repo_path": "models/dataloader/mini_imagenet.py", "max_forks_repo_name": "TJUdyk/renet", "max_forks_repo_head_hexsha": "5d066e4e08e412b1f880c63743edfdb72bdc7138", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 11, "max_forks_repo_forks_event_min_datetime": "2021-08-30T08:36:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T07:21:45.000Z", "avg_line_length": 31.7432432432, "max_line_length": 90, "alphanum_fraction": 0.5440613027, "include": true, "reason": "import numpy", "num_tokens": 565}
|
\section{Summary and Conclusions}
\label{sec:conclusions}
We have developed a realizability-preserving DG-IMEX scheme for a two-moment model of fermion transport.
The scheme employs algebraic closures based on Fermi-Dirac statistics and combines a time step restriction (CFL condition), a realizability-enforcing limiter, and a convex-invariant time integrator to maintain point-wise realizability of the moments.
Since the realizable domain is a convex set, the realizability-preserving property is obtained from convexity arguments, building on the framework in \cite{zhangShu_2010a}.
In the applications motivating this work, the collision term is stiff in regions of the computational domain, and we have considered IMEX schemes to avoid treating the transport operator implicitly.
We have considered two recently proposed second-order accurate, convex-invariant IMEX schemes \cite{chertock_etal_2015,hu_etal_2018}, that restore second-order accuracy with an implicit correction step.
However, we are unable to prove realizability (without invoking a very small time step) with the approach in \cite{chertock_etal_2015}, and we have demonstrated that the approach in \cite{hu_etal_2018} does not perform well in the diffusion limit.
For these reasons, we have resorted to first-order, convex-invariant IMEX schemes.
While the proposed scheme (dubbed PD-ARS) is formally only first-order accurate, it works well in the diffusion limit, is convex-invariant with a reasonable time step, and reduces to the optimal second-order accurate explicit SSP-RK scheme in the streaming limit.
For each stage of the IMEX scheme, the update of the cell-averaged moments can be written as a convex combination of forward Euler steps (implying the Shu-Osher form for the explicit part), followed by a backward Euler step.
Realizability of the cell-averaged moments due to the explicit part requires the DG solution to be realizable in a finite number of quadrature points in each element and the time step to satisfy a CFL condition.
For the backward Euler step, realizability of the cell-averages follows easily from the simple form of the collision operator (which includes emission, absorption, and isotropic scattering without energy exchange), and is independent of the time step.
The CFL condition is then solely due to the transport operator, and the time step can be as large as that of the forward Euler scheme applied to the explicit part of the cell-average update.
After each stage update, the limiter enforces moment realizability point-wise by damping towards the realizable cell average.
Numerical experiments are presented to demonstrate the accuracy and realizability-preserving property of the DG-IMEX scheme.
The applicability of the PD-ARS scheme is not restricted to the fermionic two-moment model.
It may therefore be a useful option in other applications of kinetic theory where physical constraints confine solutions to a convex set and capturing the diffusion limit is important.
Realizability of the fermionic two-moment model depends sensitively on the closure procedure.
For the algebraic closures adapted in this work, realizability of the scheme demands that lower and upper bounds on the Eddington factor are satisfied \cite{levermore_1984,lareckiBanach_2011}.
The Eddington factors deriving from the maximum entropy closures of Cernohorsky \& Bludman \cite{cernohorskyBludman_1994} and Larecki \& Banach \cite{lareckiBanach_2011}, and the Kershaw-type closure of Larecki \& Banach \cite{banachLarecki_2017a} all satisfy these bounds and are suitable for the fermionic two-moment model.
Further approximations of the closure procedure (e.g., employing the low occupancy limit, which results in the Minerbo closure \cite{minerbo_1978} when starting with the maximum entropy closure of \cite{cernohorskyBludman_1994}) is not compatible with realizability of the fermionic two-moment model, and we caution against this approach to modeling particle systems governed by Fermi-Dirac statistics; particularly if the low occupancy approximation is unlikely to hold (e.g., when modeling neutrino transport in core-collapse supernovae).
In this work, we started with a relatively simple kinetic model.
In particular, we adopted Cartesian coordinates, and assumed a linear collision operator and a fixed material background.
Scattering with energy exchange and relativistic effects (e.g., due to a moving material and the presence of a strong gravitational field) were not included.
To solve more realistic problems of scientific interest, some or all of these physical effects will have to be included.
In the context of developing realizability-preserving schemes, these extensions will provide significant challenges suitable for future investigations, for which the scheme presented here may serve as a foundation.
|
{"hexsha": "8c39a14fd89c0b670f4610105fa48dbc1619739c", "size": 4881, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "Documents/M1/realizableFermionicM1/sections/conclusion.tex", "max_stars_repo_name": "srichers/thornado", "max_stars_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2019-12-08T16:16:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-24T19:31:21.000Z", "max_issues_repo_path": "Documents/M1/realizableFermionicM1/sections/conclusion.tex", "max_issues_repo_name": "srichers/thornado", "max_issues_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2019-07-10T20:13:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-11T13:21:00.000Z", "max_forks_repo_path": "Documents/M1/realizableFermionicM1/sections/conclusion.tex", "max_forks_repo_name": "srichers/thornado", "max_forks_repo_head_hexsha": "bc6666cbf9ae8b39b1ba5feffac80303c2b1f9a8", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2018-11-14T01:13:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T02:08:20.000Z", "avg_line_length": 152.53125, "max_line_length": 542, "alphanum_fraction": 0.8168408113, "num_tokens": 1049}
|
import cv2
import numpy as np
import time
import threading
import queue
from xavier_config import qsize
class VideoStream(threading.Thread):
def __init__(self, url, pos, frame_q, resolution=(360, 640), threaded=False):
super(VideoStream, self).__init__()
self.cam = cv2.VideoCapture(url)
self.pos = pos
self.url = url
self.resolution = resolution
self.threaded = threaded
self.emptyframe = self.make_empty_frame()
self.num_empty_frames = 0
self.frame_q = frame_q
self.stoprequest = threading.Event()
self.daemon = True
def __repr__(self):
return "VideoStream object at url: {}".format(self.url)
def make_empty_frame(self):
frame=np.zeros((*self.resolution, 3), dtype=np.uint8)
empty_msg='Cannot read camera at {}'.format(self.url)
cv2.putText(frame, empty_msg, (50, 50),cv2.FONT_HERSHEY_COMPLEX, 0.6, (255, 255, 255))
return frame
def read(self, framebuffer, threaded=False):
ret, frame = self.cam.read()
if ret:
this_frame = frame
else:
self.num_empty_frames += 1
this_frame = self.emptyframe
if self.num_empty_frames >= 10:
self.reset()
if self.threaded:
return this_frame
else:
if self.pos == 1:
framebuffer[:self.resolution[0],
:self.resolution[1]] = this_frame
elif self.pos == 2:
framebuffer[:self.resolution[0],
self.resolution[1]:] = this_frame
elif self.pos == 3:
framebuffer[self.resolution[0]:,
:self.resolution[1]] = this_frame
elif self.pos == 4:
framebuffer[self.resolution[0]:,
self.resolution[1]:] = this_frame
def cleanup(self):
self.cam.release()
def reset(self):
self.cleanup()
self.cam = cv2.VideoCapture(self.url)
self.num_empty_frames = 0
print(self.__repr__(), ' was reset')
def run(self):
print('Running stream for ', self.__repr__())
if self.threaded:
while not self.stoprequest.isSet():
# framebuffer is just a dummy here
frame = self.read(0, threaded=True)
if self.frame_q.full():
_ = self.frame_q.get_nowait()
# this will never raise an exception
self.frame_q.put_nowait(frame)
# if this thread is the only producer using this queue
def join(self, timeout=None):
self.stoprequest.set()
self.cleanup()
super(VideoStream, self).join(timeout)
class VideoStreamHandler(object):
def __init__(self, urls, threaded=False, resolution=(360, 640)):
#super(VideoStreamHandler, self).__init__()
assert len(urls) == 4, 'At the moment this code can handle only 4 streams'
self.url1 = urls[0]
self.url2 = urls[1]
self.url3 = urls[2]
self.url4 = urls[3]
self.threaded = threaded
self.resolution = resolution
self.q1, self.q2, self.q3, self.q4 = self.setup_queues()
self.s1, self.s2, self.s3, self.s4 = self.setup_streams()
self.framebuffer = np.zeros(
(2 * resolution[0], 2 * resolution[1], 3), dtype=np.uint8)
self.emptyframes=[self.s1.emptyframe,self.s2.emptyframe,self.s3.emptyframe,self.s4.emptyframe]
if self.threaded:
self.start_streams()
def setup_streams(self):
stream1 = VideoStream(self.url1, 1, self.q1,
self.resolution, self.threaded)
stream2 = VideoStream(self.url2, 2, self.q2,
self.resolution, self.threaded)
stream3 = VideoStream(self.url3, 3, self.q3,
self.resolution, self.threaded)
stream4 = VideoStream(self.url4, 4, self.q4,
self.resolution, self.threaded)
return stream1, stream2, stream3, stream4
def setup_queues(self):
if self.threaded:
return queue.Queue(maxsize=qsize), queue.Queue(maxsize=qsize),\
queue.Queue(maxsize=qsize), queue.Queue(maxsize=qsize)
else:
return None, None, None, None
def start_streams(self):
self.s1.start()
self.s2.start()
self.s3.start()
self.s4.start()
def join_streams(self):
self.s1.join()
self.s2.join()
self.s3.join()
self.s4.join()
def read_streams(self):
if self.threaded:
self.read_queue(self.q1, 1)
self.read_queue(self.q2, 2)
self.read_queue(self.q3, 3)
self.read_queue(self.q4, 4)
else:
self.s1.read(self.framebuffer)
self.s2.read(self.framebuffer)
self.s3.read(self.framebuffer)
self.s4.read(self.framebuffer)
return self.framebuffer
def read_queue(self, q, pos):
if q.empty():
frame=self.emptyframes[pos-1]
else:
frame = q.get_nowait() # this will never raise an exception
# if this thread is the only consumer using this queue
if pos == 1:
self.framebuffer[:self.resolution[0], :self.resolution[1]] = frame
elif pos == 2:
self.framebuffer[:self.resolution[0], self.resolution[1]:] = frame
elif pos == 3:
self.framebuffer[self.resolution[0]:, :self.resolution[1]] = frame
elif pos == 4:
self.framebuffer[self.resolution[0]:, self.resolution[1]:] = frame
def run(self):
while not self.stoprequest.isSet():
frame1 = self.read_queue(self.q1)
frame2 = self.read_queue(self.q2)
frame3 = self.read_queue(self.q3)
frame4 = self.read_queue(self.q4)
self.framebuffer[:self.resolution[0], :self.resolution[1]] = frame1
self.framebuffer[:self.resolution[0], self.resolution[1]:] = frame2
self.framebuffer[self.resolution[0]:, :self.resolution[1]] = frame3
self.framebuffer[self.resolution[0]:, self.resolution[1]:] = frame4
def close(self):
self.s1.cleanup()
self.s2.cleanup()
self.s3.cleanup()
self.s4.cleanup()
def main():
fps = 0
url1 = 'http://pi1.local:8000/stream.mjpg'
url2 = 'http://pi2.local:8000/stream.mjpg'
url3 = 'http://pi3.local:8000/stream.mjpg'
url4 = 'http://pi4.local:8000/stream.mjpg'
stream_handler = VideoStreamHandler(
[url1, url2, url3, url4],threaded=False, resolution=(360, 640))
tic = time.time()
while True:
frame = stream_handler.read_streams()
toc = time.time()
fps = 0.9 * fps + 0.1 / (toc - tic)
tic = time.time()
fps_text = 'FPS:{:.2f}'.format(fps)
font = cv2.FONT_HERSHEY_PLAIN
line = cv2.LINE_AA
cv2.putText(frame, fps_text, (20, 60), font,
4.0, (255, 255, 255), 4, line)
cv2.imshow('Streams', frame)
k = cv2.waitKey(1)
if k == ord('q'):
break
if __name__ == '__main__':
main()
|
{"hexsha": "7c5dea8b3325b442440b8413ee23c1fce310ff90", "size": 7318, "ext": "py", "lang": "Python", "max_stars_repo_path": "xavier/streamutils.py", "max_stars_repo_name": "igarag/homesecurity", "max_stars_repo_head_hexsha": "35e9ea3b02fbeed771ad9d7c1bd474c36b8b64d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 150, "max_stars_repo_stars_event_min_datetime": "2019-08-25T13:57:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T13:28:34.000Z", "max_issues_repo_path": "xavier/streamutils.py", "max_issues_repo_name": "igarag/homesecurity", "max_issues_repo_head_hexsha": "35e9ea3b02fbeed771ad9d7c1bd474c36b8b64d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 19, "max_issues_repo_issues_event_min_datetime": "2019-09-01T06:05:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T01:19:48.000Z", "max_forks_repo_path": "xavier/streamutils.py", "max_forks_repo_name": "igarag/homesecurity", "max_forks_repo_head_hexsha": "35e9ea3b02fbeed771ad9d7c1bd474c36b8b64d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 46, "max_forks_repo_forks_event_min_datetime": "2019-08-25T17:31:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T22:08:31.000Z", "avg_line_length": 33.8796296296, "max_line_length": 102, "alphanum_fraction": 0.5657283411, "include": true, "reason": "import numpy", "num_tokens": 1756}
|
# Main window and functions of the ephys analysis program
import sys
from PyQt5.QtCore import Qt, pyqtSlot, QEvent
from PyQt5.QtWidgets import QMainWindow, QAction, QLabel, QGridLayout, \
QPushButton, QButtonGroup, QRadioButton, QVBoxLayout, QHBoxLayout, \
QTextEdit, QWidget, QFileDialog, QApplication, QCheckBox,\
QMessageBox, QLineEdit, QComboBox
import pickle
import numpy as np
import pandas as pd
from .ap import AP
from .sealTest import SealTest
from .mini import Mini
from .sub import Sub
from .multiPlot import MultiPlot
from .analyzeModule import AnalyzeModuleWindow
from .project import Project
from .param import ParamMan
from .projectDialog import ProjectDialog
from .selectCellDialog import SelectCellDialog
from .assignDialog import AssignDialog
from .plotWindow import PlotWindow, SimplePlotWindow
from .filterWin import FilterWin
class wcpMainWindow(QMainWindow):
'''
Main window and functions of whole cell patch clamp recording
results analysis.
'''
def __init__(self):
super().__init__()
self.proj = Project()
self.param = ParamMan()
self.projDg = ProjectDialog(self)
self.selectDg = SelectCellDialog(self)
self.selectDg.rejected.connect(self.disconnectSelectDg)
self.filterDg = FilterWin(self.proj.getDefaultFilters("str"),
parent = self)
self.plotWindows = []
self.analyzeWindows = {}
self.initUI()
self.modules = [] # list with all the modules
self.addModule("Action potential", AP)
self.addModule("Seal test", SealTest)
self.addModule("Mini analysis", Mini)
self.addModule("Subthreshold response analysis", Sub)
self.addModule("Multiple trace plot", MultiPlot)
self.show()
def initUI(self):
'''
Build the UI, all analysis functions are in the menu and the
main window has controls for browsing the traces.
'''
menubar = self.menuBar()
menubar.setNativeMenuBar(False)
fileMenu = menubar.addMenu("&File")
projectMenu = menubar.addMenu("Project")
self.analysisMenu = menubar.addMenu("&Analysis")
processMenu = menubar.addMenu("Process")
projNewAct = QAction("New project", self)
projLoadAct = QAction("Load project", self)
projSaveAct = QAction("Save project", self)
projSaveAsAct = QAction("Save project as", self)
exitAct = QAction("Exit", self)
exitAct.setShortcut("Ctrl + Q")
paramImportAct = QAction("Import parameters", self)
paramExportAct = QAction("Export parameters", self)
filterAct = QAction("Filtering", self)
fileMenu.addAction(projNewAct)
fileMenu.addAction(projLoadAct)
fileMenu.addAction(projSaveAct)
fileMenu.addAction(projSaveAsAct)
fileMenu.addAction(exitAct)
self.analysisMenu.addAction(paramImportAct)
self.analysisMenu.addAction(paramExportAct)
self.analysisMenu.addSeparator()
processMenu.addAction(filterAct)
self.projNameLb = QLabel("Name:")
self.workDirLb = QLabel("Working Directory:")
self.baseFldLb = QLabel("Raw Data Folder:")
self.formatLb = QLabel("Data file name format:")
eles = (self.projNameLb, self.workDirLb, self.baseFldLb,
self.formatLb)
projDispGrid = QGridLayout()
for i, ele in enumerate(eles):
projDispGrid.addWidget(ele, i, 0)
editProjAct = QAction("Edit project", self)
selectCellAct = QAction("Select cells", self)
assignProtTAct = QAction("Assign by trials", self)
assignProtSAct = QAction("Assign by stimulus type", self)
assignTypAct = QAction("Assign cell types", self)
projectMenu.addAction(editProjAct)
projectMenu.addAction(selectCellAct)
assignProtMenu = projectMenu.addMenu("Assign protocol")
assignProtMenu.addAction(assignProtTAct)
assignProtMenu.addAction(assignProtSAct)
projectMenu.addAction(assignTypAct)
self.cellCb = QComboBox(self)
optionBg = QButtonGroup(self)
optionBg.setExclusive(True)
self.trialRb = QRadioButton("Trial")
self.stimRb = QRadioButton("Stim")
optionBg.addButton(self.trialRb)
optionBg.addButton(self.stimRb)
self.trialRb.setChecked(True)
self.trialCbb = QComboBox(self)
self.protocolCb = QComboBox(self)
self.stimCbb = QComboBox(self)
self.normCb = QCheckBox("Normalize")
self.normWin1Le = QLineEdit(self)
self.normWin2Le = QLineEdit(self)
displayBtn = QPushButton("Display")
appendBtn = QPushButton("Append")
plotCtlGrid = QGridLayout()
eles = (QLabel("Cell"), self.cellCb, QLabel("Trial"), self.trialCbb,
self.trialRb, None, QLabel("Protocol"), self.protocolCb,
self.stimRb, None, QLabel("Stim"), self.stimCbb,
self.normCb, QLabel("Window"), self.normWin1Le, self.normWin2Le,
displayBtn, None, appendBtn, None)
positions = [(i, j) for i in range(5) for j in range(4)]
for ele, position in zip(eles, positions):
if ele == None:
continue
else:
plotCtlGrid.addWidget(ele, *position)
ctlVB = QVBoxLayout()
ctlVB.addLayout(projDispGrid)
ctlVB.addLayout(plotCtlGrid)
self.outText = QTextEdit(self)
self.outText.setReadOnly(True)
self.inText = QLineEdit(self)
ioVB = QVBoxLayout()
ioVB.addWidget(self.outText)
ioVB.addWidget(self.inText)
topHB = QHBoxLayout()
topHB.addLayout(ctlVB)
topHB.addLayout(ioVB)
placeHolderWidget = QWidget()
placeHolderWidget.setLayout(topHB)
self.setCentralWidget(placeHolderWidget)
self.projDg.edited.connect(self.updateProj)
projNewAct.triggered.connect(lambda: self.saveProj("new"))
projLoadAct.triggered.connect(self.loadProj)
projSaveAct.triggered.connect(self.saveProj)
projSaveAsAct.triggered.connect(lambda: self.saveProj("as"))
exitAct.triggered.connect(self.close)
editProjAct.triggered.connect(lambda: self.projDg.open(self.proj))
selectCellAct.triggered.connect(self.selectCells)
assignTypAct.triggered.connect(self.assignTyp)
assignProtTAct.triggered.connect(self.assignProtByTrialSelect)
assignProtSAct.triggered.connect(self.assignProtByTypeSelectCell)
self.trialRb.clicked.connect(self.updateTrialsBySelection)
self.stimRb.clicked.connect(self.updateProtocols)
self.cellCb.currentTextChanged.connect(self.updateTrialsByCell)
self.cellCb.currentTextChanged.connect(self.updateStimsByCellOrProtocol)
self.protocolCb.currentTextChanged.connect(self.updateStimsByCellOrProtocol)
self.stimCbb.currentTextChanged.connect(self.updateTrialsByStim)
displayBtn.clicked.connect(self.disp)
appendBtn.clicked.connect(self.appDisp)
paramImportAct.triggered.connect(self.importParams)
paramExportAct.triggered.connect(self.exportParams)
filterAct.triggered.connect(self.filterDg.show)
self.filterDg.filterApplied.connect(self.setFilters)
def saveProj(self, mode = "save"):
'''
Manage saving project process.
Parameters
----------
mode: string, optional
Saving mode.
"save" - Save to known project file, if not specified yet,
open a dialog to ask for a new one. Default.
"new" - Create a new project, open a dialog to ask for a
new project file and clear current parameters.
"as" - Save to a new project file, specified through dialogs.
'''
if mode == "new" and self.changeable():
target = QFileDialog.getSaveFileName(self, "New project",
self.proj.workDir + "/untitled.p")
target = target[0]
if len(target):
self.proj.clear()
self.proj.projFile = target
self.proj.save(target)
self.updateDisp()
elif mode == "as" or len(self.proj.projFile) == 0:
target = QFileDialog.getSaveFileName(self, "Save project as",
self.proj.workDir + "/untitled.p")
target = target[0]
if len(target):
self.proj.save(target)
else:
self.proj.save()
def loadProj(self):
'''
Load project from a file specified using a dialog.
'''
if self.changeable():
try:
target = QFileDialog.getOpenFileName(self, "Load project")[0]
if len(target):
self.proj.load(target)
self.updateDisp()
self.filterDg.applyFilters(0) # apply filters to this project
except pickle.UnpicklingError:
QMessageBox.warning(self, "Warning", "Wrong file format.",
QMessageBox.Ok)
else:
QMessageBox.warning(self, "Warning", "Analysis running.",
QMessageBox.Ok)
@pyqtSlot(Project)
def updateProj(self, prj):
self.proj.edit(prj)
self.updateDisp()
def updateDisp(self):
'''
Update basic project parameters display. Also update display in modules.
Also update cell and trial list comboboxes in the diplay region.
'''
self.projNameLb.setText("Name:" + self.proj.name)
self.workDirLb.setText("Working Directory:" + self.proj.workDir)
self.baseFldLb.setText("Raw Data Folder:" +
'\n'.join(self.proj.baseFolder))
self.formatLb.setText("Data file name format:" + \
self.proj.genName(1, 1))
self.trialRb.setChecked(True)
# Also update module.
self.updateModule()
# Also update cell list.
self.cellCb.clear()
if len(self.proj.baseFolder):
cl = self.proj.getCells()
for c in cl:
self.cellCb.addItem(str(c))
self.cellCb.setCurrentIndex(0)
@pyqtSlot(str)
def updateTrialsByCell(self, cell):
'''
Update trial list in the display region when a cell is selected.
Parameters
----------
cell: string
Id of selected cell in the cell list.
'''
if len(cell) and self.trialRb.isChecked():
tl = self.proj.getTrials([int(cell)])
self.trialCbb.clear()
for t in tl:
self.trialCbb.addItem(str(t))
@pyqtSlot(str)
def updateTrialsByStim(self, stim):
'''
Update trial list when a stimuation is selected.
Parameters
----------
stim: string
Stimualtion from the stimulation list.
'''
if len(stim):
c = int(self.cellCb.currentText())
p = self.protocolCb.currentText()
s = float(self.stimCbb.currentText())
tl = self.proj.getTrials([c], p, s)
self.trialCbb.clear()
for t in tl:
self.trialCbb.addItem(str(t))
def updateTrialsBySelection(self, _):
'''
Update the trial list when display by trial mode is selected.
'''
c = self.cellCb.currentText()
if len(c):
tl = self.proj.getTrials([int(c)])
self.trialCbb.clear()
for t in tl:
self.trialCbb.addItem(str(t))
def updateProtocols(self, _):
'''
Update protocol list in the display region when display by stimulation
mode is selected.
'''
pl = self.proj.getProtocols()
self.protocolCb.clear()
if len(pl):
for p in pl:
self.protocolCb.addItem(p)
self.protocolCb.setCurrentIndex(0)
@pyqtSlot(str)
def updateStimsByCellOrProtocol(self, arg):
'''
Update stimulation list in the display region when a new protocol
is selected or a new cell is selected.
'''
# only update when display by stimulation mode is selected.
if self.stimRb.isChecked():
c = int(self.cellCb.currentText())
p = self.protocolCb.currentText()
sl = self.proj.getStims(c, p)
self.stimCbb.clear()
for s in sl:
self.stimCbb.addItem(str(s))
if len(sl):
self.stimCbb.setCurrentIndex(0)
def updateModule(self):
'''
Update display of protocols in modules after changes.
'''
for _, m in self.analyzeWindows.items():
m.updateDisp(False)
def selectCells(self):
'''
Select cells that will be analyzed in this project.
'''
if self.changeable():
try:
inc = self.proj.getSelectedCells()
exc = list(set(self.proj.getCells()) - set(inc))
self.selectDg.selected.connect(self.proj.selectCells)
self.selectDg.start(inc, exc)
except (FileNotFoundError, TypeError):
QMessageBox.warning(self, "Warning", "Base Folder not specified.",
QMessageBox.Ok)
else:
QMessageBox.warning(self, "Warning", "Analysis running.",
QMessageBox.Ok)
def assignTyp(self):
'''
Dialogue window for assigned types to selected cells.
'''
if self.changeable():
try:
df = self.proj.getAssignedType()
assignDg = AssignDialog(df, self)
assignDg.start()
assignDg.assigned.connect(self.proj.assignType)
except FileNotFoundError:
QMessageBox.warning(self, "Warning", "Base Folder not specified.",
QMessageBox.Ok)
else:
QMessageBox.warning(self, "Warning", "Analysis running.",
QMessageBox.Ok)
def assignProtByTrialSelect(self):
'''
Select cells for assigning protocols.
'''
if self.changeable():
try:
inc = self.proj.getSelectedCells()
exc = list(set(self.proj.getCells()) - set(inc))
self.selectDg.selected.connect(self.assignProtByTrial)
self.selectDg.start(inc, exc)
except FileNotFoundError:
QMessageBox.warning(self, "Warning", "Base Folder not specified.",
QMessageBox.Ok)
else:
QMessageBox.warning(self, "Warning", "Analysis running.",
QMessageBox.Ok)
@pyqtSlot(tuple)
def assignProtByTrial(self, cells):
'''
Using assigning dialogue to assign protocols for trials in selected
cells
'''
self.trialRb.setChecked(True)
trials = self.proj.getTrials(cells[0])
df = pd.DataFrame([], index = pd.Index(trials, name = "trial"),
columns = ["protocol"])
df["protocol"] = ''
assignDg = AssignDialog(df, self)
assignDg.start()
assignDg.assigned.connect(lambda labels:
self.proj.assignProtocol(cells[0], labels))
assignDg.assigned.connect(self.updateModule)
self.disconnectSelectDg()
self.selectDg.selected.connect(self.proj.selectCells)
def assignProtByTypeSelectCell(self):
'''
Select cells for assigning protocols by stimulation type.
'''
if self.changeable():
try:
inc = self.proj.getSelectedCells()
exc = list(set(self.proj.getCells()) - set(inc))
self.selectDg.changeTarget("Cells")
self.selectDg.selected.connect(self.assignProtByTypeSelectTrial)
self.selectDg.start(inc, exc)
except FileNotFoundError:
QMessageBox.warning(self, "Warning", "Base Folder not specified.",
QMessageBox.Ok)
else:
QMessageBox.warning(self, "Warning", "Analysis running.",
QMessageBox.Ok)
@pyqtSlot(tuple)
def assignProtByTypeSelectTrial(self, cells):
'''
Select trials for assigning protocols by stimulation type.
Parameters
----------
cells: tuple
Selected cells.
Attribute
---------
cellsForProtAssign: tuple
Selected cells, temporary used for assigning protocol by types.
'''
self.cellsForProtAssign = cells[0]
inc = self.proj.getTrials(cells[0])
exc = []
self.selectDg.changeTarget("Trials")
self.selectDg.selected.disconnect()
self.selectDg.selected.connect(self.assignProtByType)
self.selectDg.start(inc, exc)
@pyqtSlot(tuple)
def assignProtByType(self, trials):
'''
Assign protocols based on stimulation types of trials from
self.cellsForProtAssign.
'''
self.disconnectSelectDg()
self.trialRb.setChecked(True)
stimTypes = self.proj.getStimType(self.cellsForProtAssign, trials[0])
types = np.unique(stimTypes["type"])
df = pd.DataFrame([], index = pd.Index(types, name = "stim"),
columns = ["protocol"])
df["protocol"] = ''
assignDg = AssignDialog(df, self)
ret = assignDg.exec_()
if ret:
df = assignDg.df
stimTypes["protocol"] = ''
for i in df.index:
stimTypes.loc[stimTypes["type"] == i, "protocol"] = \
df.loc[i, "protocol"]
prot = {}
cells = np.unique(stimTypes["cell"])
for c in cells:
prot[c] = stimTypes.loc[stimTypes["cell"] == c,
["trial", "stim", "protocol"]].set_index("trial")
self.proj.assignProtocol(cells, prot)
self.updateModule()
def disconnectSelectDg(self):
'''
Disconnect slots to selected signals when exiting cell selection
Dialog. Also reset the displayed target.
'''
self.selectDg.selected.disconnect()
self.selectDg.changeTarget('')
def display(self, win):
'''
Display the selected traces in a plotting window.
Parameters
----------
win: PlotWindow
Window in which the trace will be plotted.
'''
cid = int(self.cellCb.currentText())
tid = int(self.trialCbb.currentText())
trace, sr, _ = self.proj.loadWave(cid, tid)
xt = np.arange(len(trace)) / sr
# normalize to baseline
if self.normCb.isChecked():
win1 = int(sr * float(self.normWin1Le.text()))
win2 = int(sr * float(self.normWin2Le.text()))
assert win2 > win1 and 0 <= win1 and win2 <= len(trace)
trace_ = trace - np.mean(trace[win1:win2])
win.plot(xt, trace_, name = "cell{}_trial{}_norm".format(cid, tid))
else:
trace_ = trace
win.plot(xt, trace_, name = "cell{}_trial{}".format(cid, tid))
def disp(self):
'''
Create a new plotting window and display traces.
'''
try:
w = PlotWindow(self)
self.plotWindows.append(w)
w.focusInSig.connect(lambda: self.promotePlot(w))
w.closeSig.connect(lambda: self.removePlotWin(w))
self.display(w)
except FileNotFoundError as e:
w = self.plotWindows[-1]
w.close()
QMessageBox.warning(self, "Warning", e.strerror, QMessageBox.Ok)
except (ValueError, AssertionError):
w = self.plotWindows[-1]
w.close()
QMessageBox.warning(self, "Warning", "Wrong number.",
QMessageBox.Ok)
def appDisp(self):
'''
Display trace by appending to active plot window.
'''
try:
self.display(self.plotWindows[-1])
except IndexError:
QMessageBox.warning(self, "Warning", "Plot window doesn't exist.",
QMessageBox.Ok)
except ValueError:
QMessageBox.warning(self, "Warning", "Wrong number.",
QMessageBox.Ok)
except FileNotFoundError as e:
QMessageBox.warning(self, "Warning", e, QMessageBox.Ok)
def promotePlot(self, pw):
'''
Promote a window as active window.
'''
i = self.plotWindows.index(pw)
self.plotWindows.append(self.plotWindows.pop(i))
def removePlotWin(self, pw):
'''
Promote a window as active window.
'''
i = self.plotWindows.index(pw)
self.plotWindows.pop(i)
del(pw)
def exportParams(self):
'''
Pop up a dialog to get a file directory and save current parameters
to it.
'''
changed = 1
for _, m in self.analyzeWindows.items():
changed *= m.changeParams()
if changed:
target = QFileDialog.getSaveFileName(self, "Export parameters",
self.proj.workDir + "/params.yml")[0]
try:
if len(target):
self.param.save(target)
except FileNotFoundError as e:
QMessageBox.warning(self, "Warning", e.strerror, QMessageBox.Ok)
def importParams(self):
'''
Pop up a dialog to get a file directory and read parameters from it.
'''
target = QFileDialog.getOpenFileName(self, "Import parameters",
self.proj.workDir)[0]
try:
if len(target):
self.param.load(target)
for _, m in self.analyzeWindows.items():
m.updateDisp()
except FileNotFoundError as e:
QMessageBox.warning(self, "Warning", e.strerror, QMessageBox.Ok)
except (UnicodeDecodeError, KeyError):
QMessageBox.warning(self, "Warninig", "Wrong format.")
def addModule(self, name, module):
'''
Add analysis module to the program, making dialogue for controlling
and parameter setting, making signal slot connections.
Parameters
----------
name: string
Name of this module, will be shown in the menu.
module: class
Module class use to define the instances to do the analysis.
*args:
Triplets of functionality names, the actual function in the
module to do the job and parameter key.
'''
m = module(self.inText, self.proj)
m.textOut.connect(self.printTxt)
m.plotOut.connect(self.plotTrace)
m.plotLink.connect(self.linkTrace)
m.plotClear.connect(self.clearTrace)
self.modules.append(m)
analyzeModAct = QAction(name, self)
self.analysisMenu.addAction(analyzeModAct)
analyzeModAct.triggered.connect(
lambda: self.runModule(name, m))
# update parameters with default parameters
_, prof = m.profile()
self.param.set("basic_" + name, m.loadDefault("basic")) # basic
for p in prof:
self.param.set(p["pname"], m.loadDefault(p["pname"]))
def runModule(self, name, module):
'''
Build the window to run the module if not built yet, otherwise
set focus to that window.
Parameters
----------
name: string
Name of this module, will be shown in the menu.
module: object
Module class instance use to do the analysis.
*args:
Triplets of functionality names, the actual function in the
module to do the job and parameter key.
'''
if name in self.analyzeWindows:
modWindow = self.analyzeWindows[name]
modWindow.show()
else:
modWindow = AnalyzeModuleWindow(name,
module, self.param, self.proj, self)
self.analyzeWindows[name] = modWindow
modWindow.updateDisp()
def printTxt(self, text):
'''
Print text string in to output widget and update display.
Parameters
----------
text: string
To be printed.
'''
self.outText.append(text)
self.outText.update()
def plotTrace(self, plotDict):
'''
Make a new pyqtgraph window and plot intermediate results from
analysis in it. If a window exists, plot in it.
Parameters
----------
plotDict: dict
Dictionary with plot paramters and position data.
'''
if not hasattr(self, "traceWin") or self.traceWin == None:
self.traceWin = SimplePlotWindow(self)
self.traceWin.destroyed.connect(self.resetPlotWin)
self.traceWin.showPlot(plotDict["params"], plotDict["pos"])
def linkTrace(self, pos):
'''
Link trace axes in the traceWin.
Parameters
----------
pos:
Tuple of positions of axes.
'''
if hasattr(self, "traceWin") and self.traceWin != None:
self.traceWin.linkPlot(pos[0], pos[1])
def clearTrace(self):
'''
Remove everything in the plot window.
'''
if hasattr(self, "traceWin") and self.traceWin != None:
self.traceWin.clear()
def resetPlotWin(self):
'''
Reset attribute traceWin to None when the window is closed.
'''
self.traceWin = None
def changeable(self):
'''
Check if analysis is running to determine if project properties
and parameters are changeable.
'''
for _, m in self.analyzeWindows.items():
if m.busy:
return False
return True
def setFilters(self, fs):
'''
Set filters to be applied when loading traces.
Parameters
----------
fs: list
List of dictionaries with user defined filter information.
'''
ret = self.proj.setFilters(fs)
if not ret:
QMessageBox.warning(self, "Warning",
"Wrong filter format, default used.", QMessageBox.Ok)
|
{"hexsha": "3b46dce4d7de86b27484ba7d6ee28ee87923ada7", "size": 21906, "ext": "py", "lang": "Python", "max_stars_repo_path": "whole_cell_patch/main.py", "max_stars_repo_name": "11uc/whole_cell_patch", "max_stars_repo_head_hexsha": "84e11bbb904b363a6bb5af878d46e23d789c5be0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-08-03T13:05:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-25T15:03:24.000Z", "max_issues_repo_path": "whole_cell_patch/main.py", "max_issues_repo_name": "11uc/whole_cell_patch", "max_issues_repo_head_hexsha": "84e11bbb904b363a6bb5af878d46e23d789c5be0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "whole_cell_patch/main.py", "max_forks_repo_name": "11uc/whole_cell_patch", "max_forks_repo_head_hexsha": "84e11bbb904b363a6bb5af878d46e23d789c5be0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.594972067, "max_line_length": 78, "alphanum_fraction": 0.7085273441, "include": true, "reason": "import numpy", "num_tokens": 5739}
|
//initialization related to ros
#include "ros/ros.h"
#include "std_msgs/Byte.h"
//#include "std_msgs/String.h"
//#include "dynamixel_workbench_msgs/DynamixelCommand.h"
#include <darknet_ros_msgs/BoundingBoxes.h>
#include <gb_visual_detection_3d_msgs/BoundingBoxes3d.h>
#include <python2.7/Python.h>
//#include <thread>
#include <boost/thread/thread.hpp> //use thread in ros
#define pi 3.141592653589
int pole_tag=0;
int pole_tag_flag=1;
int motor_velocity=-200;
double diameter_wheel= 0.0326; //m @
double to_rad_coef=pi/2048;
bool is_car=false;
bool is_plastic_person=false;
bool is_pix_in_tor=false;
int path_vec_update_flag=0;
int pole_rel=0;
std::vector<gb_visual_detection_3d_msgs::BoundingBox3d> detected_bboxes_; //vector로 변환
std::vector<std::string> detected_bboxes_class_;
gb_visual_detection_3d_msgs::BoundingBox3d car_box;
gb_visual_detection_3d_msgs::BoundingBox3d plastic_man_box;
double pix_x,pix_y,pix_z;
int state_store_flag=1;
int stay_for_store_flag=0;
std::vector<double> pix_car_position(3,0);
std::vector<double> toler_pix_car_position(3,0.5); //수정가능@
std::vector<double> prev_pix_car_position(3,0);
std::vector<double> tor_plus_vector(3,0);
std::vector<double> tor_minus_vector(3,0);
std::vector<int> path_vec;
std::array<int,2> pole_num_arr;
std::array<int,2> pole_angle_arr;
double pos,prev_pos,prev_pos_rad,pos_rad,distance,prev_distance;
double toler_distance=0.1;
std_msgs::Byte savetag;
std_msgs::Byte direction_roi;
std_msgs::Byte pole_angle;
void pole1_callback(const std_msgs::Byte::ConstPtr& msg)
{
if (msg->data==1){pole_tag=1;}
else{pole_tag=0;}
}
void pole2_callback(const std_msgs::Byte::ConstPtr& msg)
{
if (msg->data==1){pole_tag=2;}
else{pole_tag=0;}
}
void pole3_callback(const std_msgs::Byte::ConstPtr& msg)
{
if (msg->data==1){pole_tag=3;}
else{pole_tag=0;}
}
void pole4_callback(const std_msgs::Byte::ConstPtr& msg)
{
if (msg->data==1){pole_tag=4;}
else{pole_tag=0;}
}
/*
template<typename T>
std::string getType(T) {
std::string type = "unknown";
if (std::is_same<T, int>::value) type = "int";
if (std::is_same<T, double>::value) type = "double";
if (std::is_same<T, float>::value) type = "float";
if (std::is_same<T, bool>::value) type = "bool";
if (std::is_same<T, std::string>::value) type = "string";
return type;
}
std::cout<<getType(detected_bboxes_[i].Class)<<std::endl;
*/
void detect_box(const gb_visual_detection_3d_msgs::BoundingBoxes3d::ConstPtr& msg)
{
detected_bboxes_ = msg->bounding_boxes; //BoundingBox3d[]. 즉, array형태이다.
int size =detected_bboxes_.size();
std::string element_to_check_car="car";
std::string element_to_check_plastic_man="plastic_man";
for(int i=0;i<size;i++)
{
detected_bboxes_class_.insert(detected_bboxes_class_.begin() + i, detected_bboxes_[i].Class);
if(detected_bboxes_[i].Class=="car")
{
car_box= detected_bboxes_[i];
}
if(detected_bboxes_[i].Class=="plastic_man")
{
plastic_man_box= detected_bboxes_[i];
}
}
if (any_of(detected_bboxes_class_.begin(), detected_bboxes_class_.end(), [&](const std::string& elem) { return elem == element_to_check_car; }))
{
//printf("%s is present in the vector\n", element_to_check_car.c_str());
is_car=true;
}
else
{
//printf("%s isn't present in the vector\n", element_to_check_car.c_str());
is_car=false;
// car_box.xmax=0; car_box.xmin=0;
// car_box.ymax=0; car_box.ymin=0;
// car_box.zmax=0; car_box.zmin=0;
}
if (any_of(detected_bboxes_class_.begin(), detected_bboxes_class_.end(), [&](const std::string& elem) { return elem == element_to_check_plastic_man; }))
{
//printf("%s is present in the vector\n", element_to_check_plastic_man.c_str());
is_plastic_person=true;
}
else
{
//printf("%s isn't present in the vector\n", element_to_check_plastic_man.c_str());
is_plastic_person=false;
}
for(int i=0;i<size;i++)
{
detected_bboxes_class_.erase(detected_bboxes_class_.begin() + i);
}
}
bool pix_in_tor(std::vector<double> pix, std::vector<double> prev, std::vector<double> tor)
{
std::vector<double> tor_plus(3,0);
std::vector<double> tor_minus(3,0);
for(const auto i:prev)
{
tor_plus[i]=prev[i]+tor[i];
tor_minus[i]=prev[i]-tor[i];
if(tor_minus[i]<pix[i] && pix[i]<tor_plus[i])
{
is_pix_in_tor=true;
}
}
return is_pix_in_tor;
}
void thread_save_mode()
{
ros::NodeHandlePtr n = boost::make_shared<ros::NodeHandle>();
ros::Publisher save_pub = n->advertise<std_msgs::Byte>("/image_save_tag", 1000);
ros::Rate loop_rate(30);
while(ros::ok())
{
save_pub.publish(savetag);
loop_rate.sleep();
}
}
void thread_pole_angle()
{
ros::NodeHandlePtr n = boost::make_shared<ros::NodeHandle>();
ros::Publisher pole1_angle_pub = n->advertise<std_msgs::Byte>("pole1/pole_angle", 1000);
ros::Publisher pole2_angle_pub = n->advertise<std_msgs::Byte>("pole2/pole_angle", 1000);
ros::Publisher pole3_angle_pub = n->advertise<std_msgs::Byte>("pole3/pole_angle", 1000);
ros::Publisher pole4_angle_pub = n->advertise<std_msgs::Byte>("pole4/pole_angle", 1000);
ros::Publisher direction_roi_pub = n->advertise<std_msgs::Byte>("/direction_roi", 1000);
ros::Rate loop_rate(30);
while(ros::ok())
{
for(int i=0; i<2; i++)
{
pole_angle.data=pole_angle_arr[i];
switch(pole_num_arr[i])
{
case 2:
pole1_angle_pub.publish(pole_angle);
break;
case 5:
pole2_angle_pub.publish(pole_angle);
break;
case 4:
pole3_angle_pub.publish(pole_angle);
break;
case 6:
pole4_angle_pub.publish(pole_angle);
break;
}
}
direction_roi_pub.publish(direction_roi);
loop_rate.sleep();
}
}
void thread_pole_num() //path_vec의 2요소씩 검사.
{
ros::NodeHandlePtr n = boost::make_shared<ros::NodeHandle>();
int path_index=0;
ros::Rate loop_rate(30);
while(ros::ok())
{
if(path_vec_update_flag==1)
{
if(path_index==path_vec.size()-1)
{
path_index=0;
}
pole_num_arr[0]=path_vec[path_index];
pole_num_arr[1]=path_vec[path_index+1];
pole_rel=pole_num_arr[1]-pole_num_arr[0];
switch(pole_rel)
{
case -1: //left
pole_angle_arr[0]=3;
pole_angle_arr[1]=3;
direction_roi.data=1;
break;
case +1: //right
pole_angle_arr[0]=1;
pole_angle_arr[1]=1;
direction_roi.data=2;
break;
case +3: //up
pole_angle_arr[0]=0;
pole_angle_arr[1]=0;
direction_roi.data=0;
break;
case -3: //down
pole_angle_arr[0]=2;
pole_angle_arr[1]=2;
direction_roi.data=0;
break;
}
path_index++;
path_vec_update_flag=0;
}
loop_rate.sleep();
}
}
int main(int argc, char **argv)
{
if(argc>2)
{
for(int i=1; i<argc; i++)
{
path_vec.push_back(atoi(argv[i]));
//std::cout << path_vec[i-1] << std::endl;
}
}
else
{
ROS_ERROR("Enter a number of points 2 or more. \n\n");
}
ros::init(argc, argv, "mobile");
//ros::NodeHandle n;
ros::NodeHandlePtr n = boost::make_shared<ros::NodeHandle>();
ros::Subscriber sub1 = n->subscribe("pole1_sensor", 1000, pole1_callback);
ros::Subscriber sub2 = n->subscribe("pole2_sensor", 1000, pole2_callback);
ros::Subscriber sub3 = n->subscribe("pole3_sensor", 1000, pole3_callback);
ros::Subscriber sub4 = n->subscribe("pole4_sensor", 1000, pole4_callback);
ros::Subscriber car_box_sub = n->subscribe("/darknet_ros_3d/bounding_boxes", 1000, detect_box);
ros::Rate rate(30);
ros::Duration turn_time= ros::Duration(10); //@
ros::Duration slow_time= ros::Duration(7);
ros::Duration capture_time= ros::Duration(2);
ros::Time temp_time=ros::Time::now();
ros::Time is_car_time=ros::Time::now();
ros::Time isnot_car_time=ros::Time::now();
ros::Time stored_time=ros::Time::now();
ros::Time under_sensor_time=ros::Time::now();
PyObject *pName,*pValue,*pModule,*SET_VEL, *GET_STATUS, *CLEAR;
PyObject *pArgs;
Py_Initialize();
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append(\"/home/jelly/catkin_ws/src/rosi_controller/script\")");
pArgs = PyTuple_New(2);
pName = PyUnicode_FromString("velocity_mode_read_status"); //PyObject 생성.
pModule = PyImport_Import(pName); //생성한 PyObject pName을 import한다.
SET_VEL = PyObject_GetAttrString(pModule, "set_vel"); //실행할 함수를 PyObject에 전달.
GET_STATUS = PyObject_GetAttrString(pModule, "get_status");
CLEAR = PyObject_GetAttrString(pModule, "clear");
//pValue = PyObject_CallObject(pFunc, NULL); //매개변수(pArgs)를 전달하며 pFunc를 호출한다. 현재 매개변수가 NULL인 경우이다. return값을 받으려면 PyLong_AsLong을 써야한다.
//std::thread t1(thread_save_mode);
boost::thread t1(thread_save_mode);
boost::thread t2(thread_pole_angle);
boost::thread t3(thread_pole_num);
/*
pValue = PyObject_CallObject(GET_STATUS, NULL);
pos = PyLong_AsLong(pValue); //rad아니다. 4byte row data(-2,147,483,648 to 2,147,483,647)이다.
prev_pos_rad = pos*to_rad_coef;
double prev_degree=prev_pos_rad*(180/pi);
*/
while(ros::ok())
{
/*
pValue = PyObject_CallObject(GET_STATUS, NULL);
pos = PyLong_AsLong(pValue); //rad아니다. 4byte row data(-2,147,483,648 to 2,147,483,647)이다.
pos_rad = pos*to_rad_coef;
int degree=pos_rad*(180/pi);
degree=degree-prev_degree;
printf("%d \n", degree);
if(0<=degree%360&°ree%360<=5)
{
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
ros::Duration(3).sleep();
}
*/
if(pole_tag==1 && pole_tag_flag==1)
{
ROS_INFO("pole1_taged! \n");
under_sensor_time=ros::Time::now();
path_vec_update_flag=1;
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
turn_time.sleep(); //10초 대기
pValue = PyObject_CallObject(GET_STATUS, NULL);
prev_pos = PyLong_AsLong(pValue);
prev_pos_rad = prev_pos*to_rad_coef;
pole_tag_flag=0;
}
else if(pole_tag==2 && pole_tag_flag==1) //도착시 정지.
{
ROS_INFO("pole2_taged! \n");
under_sensor_time=ros::Time::now();
path_vec_update_flag=1;
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
turn_time.sleep(); //10초 대기
pValue = PyObject_CallObject(GET_STATUS, NULL);
prev_pos = PyLong_AsLong(pValue);
prev_pos_rad = prev_pos*to_rad_coef;
pole_tag_flag=0;
}
else if(pole_tag==3 && pole_tag_flag==1) //도착시 정지.
{
ROS_INFO("pole3_taged! \n");
under_sensor_time=ros::Time::now();
path_vec_update_flag=1;
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
turn_time.sleep(); //10초 대기
pValue = PyObject_CallObject(GET_STATUS, NULL);
prev_pos = PyLong_AsLong(pValue);
prev_pos_rad = prev_pos*to_rad_coef;
pole_tag_flag=0;
}
else if(pole_tag==4 && pole_tag_flag==1) //도착시 정지.
{
ROS_INFO("pole4_taged! \n");
under_sensor_time=ros::Time::now();
path_vec_update_flag=1;
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
turn_time.sleep(); //10초 대기
pValue = PyObject_CallObject(GET_STATUS, NULL);
prev_pos = PyLong_AsLong(pValue);
prev_pos_rad = prev_pos*to_rad_coef;
pole_tag_flag=0;
}
else
{
//default
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(motor_velocity)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(-motor_velocity));
PyObject_CallObject(SET_VEL, pArgs);
if(ros::Time::now()-under_sensor_time>ros::Duration(18))
{
pole_tag_flag=1; //sensor를 벗어난지 3초가 지났을 때 켠다. 너무 짧으면 변경해야 함.@
}
if(is_car==true && (pole_rel==1 || pole_rel==-1))
{
is_car_time=ros::Time::now(); //current_time -> is_car_time으로 바꿈. @
while(is_car_time-isnot_car_time<ros::Duration(9))
{
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(motor_velocity/2)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(-motor_velocity/2));
PyObject_CallObject(SET_VEL, pArgs);
slow_time.sleep(); //7초 대기
PyTuple_SetItem(pArgs, 0, PyLong_FromLong(0)); PyTuple_SetItem(pArgs, 1, PyLong_FromLong(0));
PyObject_CallObject(SET_VEL, pArgs);
capture_time.sleep(); //2초 대기
//store previous pixel coordinate
pix_car_position[0]=(car_box.xmax+car_box.xmin)/2.0;
pix_car_position[1]=(car_box.ymax+car_box.ymin)/2.0;
pix_car_position[2]=(car_box.zmax+car_box.zmin)/2.0;
is_car_time=ros::Time::now();
rate.sleep();
ros::spinOnce();
}
if(state_store_flag==1) //store state.
{
stored_time=ros::Time::now();
prev_pix_car_position=pix_car_position;
//printf("x: %f y: %f z: %f \n",pix_car_position[0], pix_car_position[1] ,pix_car_position[2]);
//store previous distance
pValue = PyObject_CallObject(GET_STATUS, NULL);
pos = PyLong_AsLong(pValue);
pos_rad = pos*to_rad_coef;
distance=(pos_rad-prev_pos_rad)*diameter_wheel*pi; //m
printf("distance %f \n",distance);
prev_distance=distance;
savetag.data=1;
state_store_flag=0;
}
else //비교
{
//store present position
pValue = PyObject_CallObject(GET_STATUS, NULL);
pos = PyLong_AsLong(pValue);
pos_rad = pos*to_rad_coef;
distance=(pos_rad-prev_pos_rad)*diameter_wheel*pi; //m
is_pix_in_tor=pix_in_tor(pix_car_position,prev_pix_car_position,toler_pix_car_position);
if(prev_distance-toler_distance<distance<prev_distance+toler_distance && \
is_pix_in_tor && (ros::Time::now()-stored_time)>ros::Duration(5))
{
stored_time=ros::Time::now();
prev_pix_car_position=pix_car_position;
prev_distance=distance;
savetag.data=2;
stay_for_store_flag=1;
is_pix_in_tor=false;
}
}
}
else
{
temp_time=ros::Time::now();
if(temp_time-is_car_time>ros::Duration(1))
{
isnot_car_time=ros::Time::now();
savetag.data=0;
if(stay_for_store_flag==1)
{
state_store_flag=1;
stay_for_store_flag=0;
}
}
}
}
rate.sleep();
ros::spinOnce();
}
PyObject_CallObject(CLEAR, NULL);
Py_Finalize();
t1.join();
t2.join();
t3.join();
return 0;
}
|
{"hexsha": "33af2bc16b4882fdb78c551b323761e094e62c87", "size": 17098, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "final/rosi_controller/src/mobile_tolerance.cpp", "max_stars_repo_name": "songdaegeun/school-zone-enforcement-system", "max_stars_repo_head_hexsha": "b5680909fd5a348575563534428d2117f8dc2e3f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "final/rosi_controller/src/mobile_tolerance.cpp", "max_issues_repo_name": "songdaegeun/school-zone-enforcement-system", "max_issues_repo_head_hexsha": "b5680909fd5a348575563534428d2117f8dc2e3f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "final/rosi_controller/src/mobile_tolerance.cpp", "max_forks_repo_name": "songdaegeun/school-zone-enforcement-system", "max_forks_repo_head_hexsha": "b5680909fd5a348575563534428d2117f8dc2e3f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5414141414, "max_line_length": 157, "alphanum_fraction": 0.5731079658, "num_tokens": 4504}
|
/**
* Copyright (c) 2018, University Osnabrück
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University Osnabrück nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL University Osnabrück BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Options.h
*
* Created on: Nov 21, 2010
* Author: Thomas Wiemann
*/
#ifndef OPTIONS_H_
#define OPTIONS_H_
#include <iostream>
#include <string>
#include <vector>
#include <boost/program_options.hpp>
#include <float.h>
#include "lvr2/config/BaseOption.hpp"
using std::ostream;
using std::cout;
using std::endl;
using std::string;
using std::vector;
namespace reconstruct
{
/**
* @brief A class to parse the program options for the reconstruction
* executable.
*/
class Options : public lvr2::BaseOption{
public:
/**
* @brief Ctor. Parses the command parameters given to the main
* function of the program
*/
Options(int argc, char** argv);
virtual ~Options();
/**
* @brief Returns the given voxelsize
*/
float getVoxelsize()const;
/**
* @brief Returns the number of used threads
*/
int getNumThreads() const;
/**
* @brief Prints a usage message to stdout.
*/
bool printUsage() const;
/**
* @brief Returns true if an output filen name was set
*/
bool filenameSet() const;
/**
* @brief Returns true if the face normals of the
* reconstructed mesh should be saved to an
* extra file ("face_normals.nor")
*/
bool saveFaceNormals() const;
/**
*@brief Returns true of region coloring is enabled.
*/
bool colorRegions() const;
/**
* @brief Returns true if the interpolated normals
* should be saved in the putput file
*/
bool saveNormals() const;
/**
* @brief Returns true if the Marching Cubes grid should be save
*/
bool saveGrid() const;
/**
* @brief Returns true if the original points should be stored
* together with the reconstruction
*/
bool saveOriginalData() const;
/**
* @brief Returns true if cluster optimization is enabled
*/
bool optimizePlanes() const;
/**
* @brief Indicates whether to save the used points
* together with the interpolated normals.
*/
bool savePointNormals() const;
/**
* @brief If true, normals should be calculated even if
* they are already given in the input file
*/
bool recalcNormals() const;
/**
* @brief If true, RANSAC based normal estimation is used
*/
bool useRansac() const;
/**
* @brief True if texture analysis is enabled
*/
bool doTextureAnalysis() const;
/**
* @brief If true, textures will be generated during
* finalization of mesh.
*/
bool generateTextures() const;
/**
* @brief Returns the number of neighbors
* for normal interpolation
*/
int getKi() const;
/**
* @brief Returns the number of neighbors used for
* initial normal estimation
*/
int getKn() const;
/**
* @brief Returns the number of neighbors used for distance
* function evaluation
*/
int getKd() const;
/**
* @brief Return whether the mesh should be retesselated or not.
*/
bool retesselate() const;
/**
* @brief True if region clustering without plane optimization is required.
*/
bool clusterPlanes() const;
/**
* @brief True if region clustering without plane optimization is required.
*/
bool writeClassificationResult() const;
/**
* @brief Returns the input file name
*/
string getInputFileName() const;
/**
* @brief Returns the output file name
*/
string getOutputFileName() const;
/**
* @brief Returns the output file names
*/
vector<string> getOutputFileNames() const;
/**
* @brief Returns the name of the classifier used to color the mesh
*/
string getClassifier() const;
/**
* @brief Returns the name of the given file with scan poses used for normal flipping.
*/
string getScanPoseFile() const;
/**
* @brief Returns the number of intersections. If the return value
* is positive it will be used for reconstruction instead of
* absolute voxelsize.
*/
int getIntersections() const;
/**
* @brief Returns to number plane optimization iterations
*/
int getPlaneIterations() const;
/**
* @brief Returns the name of the used point cloud handler.
*/
string getPCM() const;
/**
* @brief Returns the name of the used point cloud handler.
*/
string getDecomposition() const;
/**
* @brief Returns the normal threshold for plane optimization.
*/
float getNormalThreshold() const;
/**
* @brief Returns the threshold for the size of small
* region deletion after plane optimization.
*/
int getSmallRegionThreshold() const;
/**
* @brief Minimum value for plane optimzation
*/
int getMinPlaneSize() const;
/**
* @brief Number of iterations for contour cleanup
*/
int getCleanContourIterations() const;
/**
* @brief Returns the number of dangling artifacts to remove from
* a created mesh.
*/
int getDanglingArtifacts() const;
/**
* @brief Returns the region threshold for hole filling
*/
int getFillHoles() const;
/**
* @brief Returns the texel size for texture resolution
*/
float getTexelSize() const;
/**
* @brief Returns the sharp feature threshold when using sharp feature decomposition
*/
float getSharpFeatureThreshold() const;
/**
* @brief Returns the sharp corner threshold when using sharp feature decomposition
*/
float getSharpCornerThreshold() const;
/**
* @brief Returns the fusion threshold for tesselation
*/
float getLineFusionThreshold() const;
/**
* @brief Whether to extend the grid. Enable by default.
*/
bool extrude() const;
/**
* @brief Reduction ratio for mesh reduction via edge collapse
*/
float getEdgeCollapseReductionRatio() const;
unsigned int getNumStatsColors() const;
unsigned int getNumCCVColors() const;
unsigned int getCoherenceThreshold() const;
float getColorThreshold() const;
float getStatsThreshold() const;
float getFeatureThreshold() const;
bool getUseCrossCorr() const;
float getPatternThreshold() const;
float* getStatsCoeffs()const;
string getTexturePack() const;
int getMinimumTransformationVotes() const;
int getTexMinClusterSize() const;
int getTexMaxClusterSize() const;
bool vertexColorsFromPointcloud() const;
bool useGPU() const;
vector<float> getFlippoint() const;
bool texturesFromImages() const;
string getProjectDir() const;
private:
/// The set voxelsize
float m_voxelsize;
/// The number of uesed threads
int m_numThreads;
/// The putput file name for face normals
string m_faceNormalFile;
/// The number of used default values
int m_numberOfDefaults;
/// The number of neighbors for distance function evaluation
int m_kd;
/// The number of neighbors for normal estimation
int m_kn;
/// The number of neighbors for normal interpolation
int m_ki;
/// The number of intersections used for reconstruction
int m_intersections;
/// Whether or not the mesh should be retesselated while being finalized
bool m_retesselate;
/// Whether or not the mesh should be retesselated while being finalized
bool m_generateTextures;
/// Whether or not the classifier shall dump meta data to a file 'clusters.clu'
bool m_writeClassificationResult;
/// The used point cloud manager
string m_pcm;
/// Number of iterations for plane optimzation
int m_planeIterations;
/// Threshold for plane optimization
float m_planeNormalThreshold;
/// Threshold for small ragions
int m_smallRegionThreshold;
/// Number of dangling artifacts to remove
int m_rda;
/// Threshold for hole filling
int m_fillHoles;
/// Threshold for plane optimization
int m_minPlaneSize;
int m_cleanContourIterations;
/// Texel size
float m_texelSize;
/// Threshold for line fusing when tesselating
float m_lineFusionThreshold;
/// Sharp feature threshold when using sharp feature decomposition
float m_sft;
/// Sharp corner threshold when using sharp feature decomposition
float m_sct;
/// Name of the classifier object to color the mesh
string m_classifier;
/// Reduction ratio for mesh reduction via edge collapse
float m_edgeCollapseReductionRatio;
///Path to texture pack
string m_texturePack;
///Coefficents file for texture matching based on statistics
string m_statsCoeffs;
///Number of colors for texture statistics
unsigned int m_numStatsColors;
///Number of colors for texture matching based on color information
unsigned int m_numCCVColors;
///Coherence threshold for texture matching based on color information
unsigned int m_coherenceThreshold;
///Threshold for texture matching based on colors
float m_colorThreshold;
///Threshold for texture matching based on statistics
float m_statsThreshold;
///Threshold for texture matching based on features
float m_featuresThreshold;
///Whether to use texture matching based on cross correlation
bool m_useCrossCorr;
///Threshold for pattern extraction from textures
float m_patternThreshold;
///Minimum number of vote to consider a texture transformation as "correct"
int m_minimumTransformationVotes;
///Minimum number of textures of a cluster needed for generating textures
int m_texMinClusterSize;
int m_texMaxClusterSize;
///Use pointcloud colors to paint vertices
bool m_vertexColorsFromPointcloud;
// Flippoint for gpu normal calculation
vector<float> m_flippoint;
};
/// Overlaoeded outpur operator
inline ostream& operator<<(ostream& os, const Options &o)
{
o.printTransformation(os);
if(o.getIntersections() > 0)
{
cout << "##### Intersections \t\t: " << o.getIntersections() << endl;
}
else
{
cout << "##### Voxelsize \t\t: " << o.getVoxelsize() << endl;
}
cout << "##### Number of threads \t: " << o.getNumThreads() << endl;
cout << "##### Point cloud manager \t: " << o.getPCM() << endl;
if(o.useRansac())
{
cout << "##### Use RANSAC\t\t: YES" << endl;
}
else
{
cout << "##### Use RANSAC\t\t: NO" << endl;
}
cout << "##### Voxel decomposition: \t: " << o.getDecomposition() << endl;
cout << "##### Classifier:\t\t: " << o.getClassifier() << endl;
if(o.writeClassificationResult())
{
cout << "##### Dump classification\t: YES" << endl;
}
else
{
cout << "##### Dump classification\t: NO" << endl;
}
cout << "##### k_n \t\t\t: " << o.getKn() << endl;
cout << "##### k_i \t\t\t: " << o.getKi() << endl;
cout << "##### k_d \t\t\t: " << o.getKd() << endl;
if(o.getDecomposition() == "SF")
{
cout << "##### Sharp feature threshold \t: " << o.getSharpFeatureThreshold() << endl;
cout << "##### Sharp corner threshold \t: " << o.getSharpCornerThreshold() << endl;
}
if(o.retesselate())
{
cout << "##### Retesselate \t\t: YES" << endl;
cout << "##### Line fusion threshold \t: " << o.getLineFusionThreshold() << endl;
}
if(o.saveFaceNormals())
{
cout << "##### Write Face Normals \t: YES" << endl;
}
if(o.getFillHoles())
{
cout << "##### Fill holes \t\t: " << o.getFillHoles() << endl;
}
else
{
cout << "##### Fill holes \t\t: NO" << endl;
}
if(o.getDanglingArtifacts())
{
cout << "##### Remove DAs \t\t: " << o.getDanglingArtifacts() << endl;
}
else
{
cout << "##### Remove DAs \t\t: NO" << endl;
}
if(o.optimizePlanes())
{
cout << "##### Optimize Planes \t\t: YES" << endl;
cout << "##### Plane iterations\t\t: " << o.getPlaneIterations() << endl;
cout << "##### Normal threshold \t\t: " << o.getNormalThreshold() << endl;
cout << "##### Region threshold\t\t: " << o.getSmallRegionThreshold() << endl;
cout << "##### Region min size\t\t: " << o.getMinPlaneSize() << endl;
}
if(o.saveNormals())
{
cout << "##### Save normals \t\t: YES" << endl;
}
if(o.saveOriginalData())
{
cout << "##### Save input data \t\t: YES" << endl;
}
if(o.recalcNormals())
{
cout << "##### Recalc normals \t\t: YES" << endl;
}
if(o.savePointNormals())
{
cout << "##### Save points normals \t: YES" << endl;
}
if(o.vertexColorsFromPointcloud())
{
cout << "##### Vertex colors: \t\t: YES" << endl;
}
if(o.generateTextures())
{
cout << "##### Generate Textures \t: YES" << endl;
cout << "##### Texel size \t\t: " << o.getTexelSize() << endl;
cout << "##### Texture Min#Cluster \t: " << o.getTexMinClusterSize() << endl;
cout << "##### Texture Max#Cluster \t: " << o.getTexMaxClusterSize() << endl;
if(o.doTextureAnalysis())
{
cout << "##### Texture Analysis \t: ON" << endl;
}
else
{
cout << "##### Texture Analysis \t\t: OFF" << endl;
}
}
if(o.getEdgeCollapseReductionRatio() > 0.0)
{
cout << "##### Edge collapse reduction ratio\t: " << o.getEdgeCollapseReductionRatio() << endl;
}
if(o.useGPU())
{
cout << "##### GPU normal estimation \t: ON" << endl;
std::vector<float> flipPoint = o.getFlippoint();
cout << "##### Flippoint \t\t: ("
<< flipPoint[0] << ", "
<< flipPoint[1] << ", "
<< flipPoint[2] << ")" << endl;
}else{
cout << "##### GPU normal estimation \t: OFF" << endl;
}
return os;
}
} // namespace reconstruct
#endif /* OPTIONS_H_ */
|
{"hexsha": "366e1a7c978857bf174af29a05486a15b63c781f", "size": 16761, "ext": "hpp", "lang": "C++", "max_stars_repo_path": "src/tools/lvr2_reconstruct/Options.hpp", "max_stars_repo_name": "uos/lvr", "max_stars_repo_head_hexsha": "9bb03a30441b027c39db967318877e03725112d5", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 38.0, "max_stars_repo_stars_event_min_datetime": "2019-06-19T15:10:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T03:08:24.000Z", "max_issues_repo_path": "src/tools/lvr2_reconstruct/Options.hpp", "max_issues_repo_name": "uos/lvr", "max_issues_repo_head_hexsha": "9bb03a30441b027c39db967318877e03725112d5", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9.0, "max_issues_repo_issues_event_min_datetime": "2019-06-19T16:19:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-17T08:31:25.000Z", "max_forks_repo_path": "src/tools/lvr2_reconstruct/Options.hpp", "max_forks_repo_name": "uos/lvr", "max_forks_repo_head_hexsha": "9bb03a30441b027c39db967318877e03725112d5", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 13.0, "max_forks_repo_forks_event_min_datetime": "2019-04-16T11:50:32.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-26T07:47:44.000Z", "avg_line_length": 27.9816360601, "max_line_length": 103, "alphanum_fraction": 0.5812302369, "num_tokens": 3801}
|
from typing import Dict, Union
import numpy as np
from scipy.optimize import linear_sum_assignment # type: ignore
from ..dist import iou_dist
from ..tracks import Tracks
def calculate_id_metrics(
ground_truth: Tracks, hypotheses: Tracks, dist_threshold: float = 0.5
) -> Dict[str, Union[float, int]]:
gts = tuple(ground_truth.ids_count.keys())
gts_counts = tuple(ground_truth.ids_count.values())
hyps = tuple(hypotheses.ids_count.keys())
hyps_counts = tuple(hypotheses.ids_count.values())
n_gt, n_hyp = len(gts), len(hyps)
# The "real" shape is [n_gt, n_hyp], the rest is for fictional
# entries that are needed for FP and FN matrix to make the
# LAP problem minimize the actual loss, including for unmatched entries
matching = np.zeros((max(n_gt, n_hyp), max(n_gt, n_hyp)), dtype=np.int32)
for frame in sorted(set(ground_truth.frames).intersection(hypotheses.frames)):
dist_matrix = iou_dist(
ground_truth[frame]["detections"], hypotheses[frame]["detections"]
)
for gt_ind, hyp_ind in np.argwhere(dist_matrix < dist_threshold):
matching[
gts.index(ground_truth[frame]["ids"][gt_ind]),
hyps.index(hypotheses[frame]["ids"][hyp_ind]),
] += 1
fn_matrix, fp_matrix = np.zeros_like(matching), np.zeros_like(matching)
fp_matrix[:, :n_hyp] = np.tile(hyps_counts, (max(n_hyp, n_gt), 1))
fn_matrix[:n_gt, :] = np.tile(gts_counts, (max(n_hyp, n_gt), 1)).T
cost_matrix = fp_matrix + fn_matrix - 2 * matching
# Calculate matching as a LAP, get FN, FP and TP from matched entries
matching_inds = linear_sum_assignment(cost_matrix)
true_positive = matching[matching_inds].sum()
false_negative = fn_matrix[matching_inds].sum() - true_positive
false_positive = fp_matrix[matching_inds].sum() - true_positive
# Calculate the final results
idp = true_positive / (true_positive + false_positive)
idr = true_positive / (true_positive + false_negative)
idf1 = 2 * true_positive / (2 * true_positive + false_positive + false_negative)
return {
"IDTP": true_positive,
"IDFP": false_positive,
"IDFN": false_negative,
"IDP": idp,
"IDR": idr,
"IDF1": idf1,
}
|
{"hexsha": "a421ece6f5afcfca51e749653b86e5f8fd8da341", "size": 2290, "ext": "py", "lang": "Python", "max_stars_repo_path": "src/evaldet/mot_metrics/identity.py", "max_stars_repo_name": "traffic-ai/EvalDeT", "max_stars_repo_head_hexsha": "3b52698e1b03fb9066e3203c2f36aebfa0030aba", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-12-19T21:55:12.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T21:55:19.000Z", "max_issues_repo_path": "src/evaldet/mot_metrics/identity.py", "max_issues_repo_name": "sasp-ai/EvalDeT", "max_issues_repo_head_hexsha": "3b52698e1b03fb9066e3203c2f36aebfa0030aba", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2021-08-07T09:51:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-29T07:26:07.000Z", "max_forks_repo_path": "src/evaldet/mot_metrics/identity.py", "max_forks_repo_name": "traffic-ai/EvalDeT", "max_forks_repo_head_hexsha": "3b52698e1b03fb9066e3203c2f36aebfa0030aba", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1666666667, "max_line_length": 84, "alphanum_fraction": 0.6733624454, "include": true, "reason": "import numpy,from scipy", "num_tokens": 589}
|
#' #This source code is provided under the BSD license and is provided AS IS with no warranty or guarantee of fit for purpose. See the project's LICENSE.txt for details.
#' #Copyright Thomson Reuters 2013. All rights reserved.
#' @param dates dates
#' @param seccodes seccodes
#' @param per.seccode per.seccode
#' @export
get.unadj.daily.close <- function(dates,seccodes,per.seccode=1){
query <- sprintf("SELECT cast(P.MarketDate as Date) as date,Close_ as unadj,s.seccode FROM SECMSTR s JOIN SECMAP t ON s.SECCODE=t.SECCODE AND t.VENTYPE=34 AND Type_=1 join DS2PRIMQTPRC P ON t.VENCODE=p.INFOCODE JOIN DS2ADJ A ON A.INFOCODE=P.INFOCODE AND ADJTYPE=2 AND P.MARKETDATE BETWEEN ADJDATE AND ISNULL(ENDADJDATE,'06/06/2025') WHERE P.MarketDate between '%s' and '%s' and ExchIntCode in (12,135,145,244) and rank=1 and Close_ is not null",dates[1],dates[length(dates)])
if(per.seccode)
query <- paste(query, "and s.seccode = %s")
return(get.info.from.qad(dates, seccodes, query, "unadj", per.seccode=per.seccode))
}
|
{"hexsha": "52a85b7f752650874f4b3e2ef083767a35c1db5b", "size": 1035, "ext": "r", "lang": "R", "max_stars_repo_path": "R/get.unadj.daily.close.r", "max_stars_repo_name": "thomsonreuters/oqad", "max_stars_repo_head_hexsha": "eeebc58aebdc514513d41f572ca89b170996ae8e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-05-15T08:36:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-26T12:44:26.000Z", "max_issues_repo_path": "R/get.unadj.daily.close.r", "max_issues_repo_name": "GregLee-TR/oqad", "max_issues_repo_head_hexsha": "eeebc58aebdc514513d41f572ca89b170996ae8e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-04-15T22:06:42.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-10T10:24:05.000Z", "max_forks_repo_path": "R/get.unadj.daily.close.r", "max_forks_repo_name": "thomsonreuters/oqad", "max_forks_repo_head_hexsha": "eeebc58aebdc514513d41f572ca89b170996ae8e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2015-04-15T22:01:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-31T22:05:53.000Z", "avg_line_length": 64.6875, "max_line_length": 483, "alphanum_fraction": 0.7352657005, "num_tokens": 325}
|
// Copyright (c) 2014-2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <consensus/amount.h>
#include <net.h>
#include <signet.h>
#include <uint256.h>
#include <validation.h>
#include <test/util/setup_common.h>
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(validation_tests, TestingSetup)
static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams)
{
const int maxHalvings = 64;
const CAmount nInitialSubsidy = consensusParams.initialSubsidy;
CAmount nPreviousSubsidy = nInitialSubsidy * 2; // for height == 0
BOOST_CHECK_EQUAL(nPreviousSubsidy, nInitialSubsidy * 2);
for (int nHalvings = 0; nHalvings < maxHalvings; nHalvings++) {
int nHeight = nHalvings * consensusParams.nSubsidyHalvingInterval;
/* In Xaya, we have the special rule that the block reward was set
to 1 CHI at the beginning of the first halving period (before the
POST_ICO fork). Thus we use the *end* of the halving period
for the purpose of this test. */
nHeight += consensusParams.nSubsidyHalvingInterval - 1;
CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams);
BOOST_CHECK(nSubsidy <= nInitialSubsidy);
BOOST_CHECK_EQUAL(nSubsidy, nPreviousSubsidy / 2);
nPreviousSubsidy = nSubsidy;
}
BOOST_CHECK_EQUAL(GetBlockSubsidy(maxHalvings * consensusParams.nSubsidyHalvingInterval, consensusParams), 0);
}
BOOST_AUTO_TEST_CASE(block_subsidy_test)
{
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
TestBlockSubsidyHalvings(chainParams->GetConsensus()); // As in main
/* Testing other intervals as is done upstream doesn't work, as we would
need to craft a ConsensusRules instance for the POST_ICO fork check. */
}
BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
CAmount nSum = 0;
CAmount nLastSubsidy;
int nLastHeight = 0;
/* Updates the current state (contained in the variables this closes over)
based on the block subsidy at the given height, assuming that it is the
same from nLastHeight+1 up to height. */
const auto updateState = [&] (const int height)
{
const int numBlocks = height - nLastHeight;
BOOST_CHECK(numBlocks > 0);
const CAmount nSubsidy = GetBlockSubsidy(height, chainParams->GetConsensus());
BOOST_CHECK(nSubsidy <= 4 * COIN);
nSum += nSubsidy * numBlocks;
nLastSubsidy = nSubsidy;
BOOST_CHECK(MoneyRange(nSum));
nLastHeight = height;
};
updateState(1);
updateState(439999);
BOOST_CHECK_EQUAL(nLastSubsidy, 1 * COIN);
updateState(440000);
BOOST_CHECK(nLastSubsidy > 3 * COIN);
updateState(4199999);
BOOST_CHECK(nLastSubsidy > 3 * COIN);
updateState(4200000);
BOOST_CHECK(nLastSubsidy < 2 * COIN);
/* We need to call updateState always at the *last* block that has
a certain subsidy. Thus start iterating on the next block batch
(100k more than first halving), and always update on height-1. */
for (int height = 4300000; height < 140000000; height += 100000)
updateState(height - 1);
BOOST_CHECK_EQUAL(nLastSubsidy, CAmount{0});
/* This is the real PoW coin supply, taking rounding into account. The
final coin supply is larger by the presale amount. */
BOOST_CHECK_EQUAL(nSum, CAmount{3092157231160000});
}
BOOST_AUTO_TEST_CASE(subsidy_post_ico_fork_test)
{
const auto main = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
BOOST_CHECK_EQUAL(GetBlockSubsidy(439999, main->GetConsensus()), COIN);
BOOST_CHECK_EQUAL(GetBlockSubsidy(440000, main->GetConsensus()), 382934346);
const auto test = CreateChainParams(*m_node.args, CBaseChainParams::TESTNET);
BOOST_CHECK_EQUAL(GetBlockSubsidy(10999, test->GetConsensus()), COIN);
BOOST_CHECK_EQUAL(GetBlockSubsidy(11000, test->GetConsensus()), 10 * COIN);
const auto regtest = CreateChainParams(*m_node.args, CBaseChainParams::REGTEST);
BOOST_CHECK_EQUAL(GetBlockSubsidy(1, regtest->GetConsensus()), 50 * COIN);
}
BOOST_AUTO_TEST_CASE(signet_parse_tests)
{
ArgsManager signet_argsman;
signet_argsman.ForceSetArg("-signetchallenge", "51"); // set challenge to OP_TRUE
const auto signet_params = CreateChainParams(signet_argsman, CBaseChainParams::SIGNET);
CBlock block;
BOOST_CHECK(signet_params->GetConsensus().signet_challenge == std::vector<uint8_t>{OP_TRUE});
CScript challenge{OP_TRUE};
// empty block is invalid
BOOST_CHECK(!SignetTxs::Create(block, challenge));
BOOST_CHECK(!CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// no witness commitment
CMutableTransaction cb;
cb.vout.emplace_back(0, CScript{});
block.vtx.push_back(MakeTransactionRef(cb));
block.vtx.push_back(MakeTransactionRef(cb)); // Add dummy tx to exercise merkle root code
BOOST_CHECK(!SignetTxs::Create(block, challenge));
BOOST_CHECK(!CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// no header is treated valid
std::vector<uint8_t> witness_commitment_section_141{0xaa, 0x21, 0xa9, 0xed};
for (int i = 0; i < 32; ++i) {
witness_commitment_section_141.push_back(0xff);
}
cb.vout.at(0).scriptPubKey = CScript{} << OP_RETURN << witness_commitment_section_141;
block.vtx.at(0) = MakeTransactionRef(cb);
BOOST_CHECK(SignetTxs::Create(block, challenge));
BOOST_CHECK(CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// no data after header, valid
std::vector<uint8_t> witness_commitment_section_325{0xec, 0xc7, 0xda, 0xa2};
cb.vout.at(0).scriptPubKey = CScript{} << OP_RETURN << witness_commitment_section_141 << witness_commitment_section_325;
block.vtx.at(0) = MakeTransactionRef(cb);
BOOST_CHECK(SignetTxs::Create(block, challenge));
BOOST_CHECK(CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// Premature end of data, invalid
witness_commitment_section_325.push_back(0x01);
witness_commitment_section_325.push_back(0x51);
cb.vout.at(0).scriptPubKey = CScript{} << OP_RETURN << witness_commitment_section_141 << witness_commitment_section_325;
block.vtx.at(0) = MakeTransactionRef(cb);
BOOST_CHECK(!SignetTxs::Create(block, challenge));
BOOST_CHECK(!CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// has data, valid
witness_commitment_section_325.push_back(0x00);
cb.vout.at(0).scriptPubKey = CScript{} << OP_RETURN << witness_commitment_section_141 << witness_commitment_section_325;
block.vtx.at(0) = MakeTransactionRef(cb);
BOOST_CHECK(SignetTxs::Create(block, challenge));
BOOST_CHECK(CheckSignetBlockSolution(block, signet_params->GetConsensus()));
// Extraneous data, invalid
witness_commitment_section_325.push_back(0x00);
cb.vout.at(0).scriptPubKey = CScript{} << OP_RETURN << witness_commitment_section_141 << witness_commitment_section_325;
block.vtx.at(0) = MakeTransactionRef(cb);
BOOST_CHECK(!SignetTxs::Create(block, challenge));
BOOST_CHECK(!CheckSignetBlockSolution(block, signet_params->GetConsensus()));
}
//! Test retrieval of valid assumeutxo values.
BOOST_AUTO_TEST_CASE(test_assumeutxo)
{
const auto params = CreateChainParams(*m_node.args, CBaseChainParams::REGTEST);
// These heights don't have assumeutxo configurations associated, per the contents
// of chainparams.cpp.
std::vector<int> bad_heights{0, 100, 111, 115, 209, 211};
for (auto empty : bad_heights) {
const auto out = ExpectedAssumeutxo(empty, *params);
BOOST_CHECK(!out);
}
const auto out110 = *ExpectedAssumeutxo(110, *params);
BOOST_CHECK_EQUAL(out110.hash_serialized.ToString(), "dc81af66a58085fe977c6aab56b49630d87b84521fc5a8a5c53f2f4b23c8d6d5");
BOOST_CHECK_EQUAL(out110.nChainTx, 110U);
const auto out210 = *ExpectedAssumeutxo(200, *params);
BOOST_CHECK_EQUAL(out210.hash_serialized.ToString(), "51c8d11d8b5c1de51543c579736e786aa2736206d1e11e627568029ce092cf62");
BOOST_CHECK_EQUAL(out210.nChainTx, 200U);
}
BOOST_AUTO_TEST_SUITE_END()
|
{"hexsha": "a0871174c41fc75187990fec6284998c5b0c3863", "size": 8413, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/test/validation_tests.cpp", "max_stars_repo_name": "spaceexpanse/xaya", "max_stars_repo_head_hexsha": "49aee2d5abc0c36d6aee990e7acbc3aece2b7a82", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/test/validation_tests.cpp", "max_issues_repo_name": "spaceexpanse/xaya", "max_issues_repo_head_hexsha": "49aee2d5abc0c36d6aee990e7acbc3aece2b7a82", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1.0, "max_issues_repo_issues_event_min_datetime": "2022-02-12T18:08:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T18:08:34.000Z", "max_forks_repo_path": "src/test/validation_tests.cpp", "max_forks_repo_name": "SpaceXpanse/rod-core-wallet", "max_forks_repo_head_hexsha": "4757a1c0ead25b9094ff06baabffbe5eb4a6bb67", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2.0, "max_forks_repo_forks_event_min_datetime": "2022-01-17T14:11:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-18T14:09:32.000Z", "avg_line_length": 43.3659793814, "max_line_length": 125, "alphanum_fraction": 0.7318435754, "num_tokens": 2302}
|
from numpy.testing import assert_allclose, run_module_suite
from pyins import earth
def test_principal_radii():
lat = 0
re, rn = earth.principal_radii(lat)
assert_allclose(re, earth.R0, rtol=1e-10)
assert_allclose(rn, earth.R0 * (1 - earth.E2), rtol=1e-10)
lat = [0, 90]
re, rn = earth.principal_radii(lat)
assert_allclose(re[0], earth.R0, rtol=1e-10)
assert_allclose(rn[0], earth.R0 * (1 - earth.E2), rtol=1e-10)
assert_allclose(re[1], rn[1], rtol=1e-10)
def test_gravity():
# Another smoke test.
g = earth.gravity(0)
assert_allclose(g, 9.7803253359, rtol=1e-10)
g = earth.gravity(90)
assert_allclose(g, 9.8321849378, rtol=1e-10)
g = earth.gravity(0, 0.5)
assert_allclose(g, 9.7803253359 * (1 - 1 / earth.R0), rtol=1e-10)
g = earth.gravity([0, 0], [0, 0.5])
assert_allclose(g, [9.7803253359, 9.7803253359 * (1 - 1 / earth.R0)],
rtol=1e-10)
def test_gravitation_ecef():
g = earth.gravity(90, 100)
g0_e = earth.gravitation_ecef(90, 0, 100)
assert_allclose(g0_e, [0, 0, -g], atol=1e-12)
g = earth.gravity(0)
g0_e = earth.gravitation_ecef(0, 90)
assert_allclose(g0_e, [0, -g - earth.RATE**2 * earth.R0, 0],
atol=1e-12)
g0_true = [[0, 0, -earth.gravity(90, 100)],
[0, -earth.gravity(0) - earth.RATE**2 * earth.R0, 0]]
assert_allclose(earth.gravitation_ecef([90, 0], [0, 90], [100, 0]),
g0_true, atol=1e-12)
if __name__ == '__main__':
run_module_suite()
|
{"hexsha": "3727a4f61e7d39e04465de369c8a44716b191e62", "size": 1546, "ext": "py", "lang": "Python", "max_stars_repo_path": "pyins/tests/test_earth.py", "max_stars_repo_name": "toniklenk/pyins", "max_stars_repo_head_hexsha": "db18a6083dbd7397315095d9a5096cd515f7e248", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 52, "max_stars_repo_stars_event_min_datetime": "2017-02-22T15:51:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-13T08:02:04.000Z", "max_issues_repo_path": "pyins/tests/test_earth.py", "max_issues_repo_name": "toniklenk/pyins", "max_issues_repo_head_hexsha": "db18a6083dbd7397315095d9a5096cd515f7e248", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2018-06-04T07:16:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-29T19:44:48.000Z", "max_forks_repo_path": "pyins/tests/test_earth.py", "max_forks_repo_name": "toniklenk/pyins", "max_forks_repo_head_hexsha": "db18a6083dbd7397315095d9a5096cd515f7e248", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 26, "max_forks_repo_forks_event_min_datetime": "2018-01-29T15:09:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T11:05:38.000Z", "avg_line_length": 29.7307692308, "max_line_length": 73, "alphanum_fraction": 0.6099611902, "include": true, "reason": "from numpy", "num_tokens": 572}
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This module defines a class `PartitionExt` which extends the `Partition` class in SageMath with
methods related to the computation of the generalized core and quotient decomposition as described in [Pearce, 2020].
See the docstring of the `PartitionExt` class for a description of the available methods.
This module further includes the following functions related to constructing partitions from generalised core and quotient data
* from_G_core_and_quotient(core, quotient, r, b=-1) - Create partition from G-core-quotient decomposition w.r.t. $(r,b)$-action
* from_G_charges_and_quotient(charges, quotient, r, b=-1) - Create partition from $(r,b)$-charge coordinates and quotient
* from_G_abacus(abacus, r=None, b=-1) - Create partition from a representation of its $(r,b)$-abacus.
"""
# Standard library imports
from collections import deque # deque is list-like container with faster popleft
# SageMath imports
import sage.all # Required to run this module from a Python interpreter/kernel (not required for Sage kernel)
from sage.combinat.partition import Partition, Partitions
from sage.combinat.partition_tuple import PartitionTuple # Used for compatibility with `Partition.quotient` method
from sage.arith.all import gcd
# Local packages
__author__ = 'Edward Pearce'
__copyright__ = 'Copyright 2020, PyParti (Suanpan Project)'
__credits__ = ['Edward Pearce']
__license__ = 'MIT'
__version__ = '1.0.0'
__maintainer__ = 'Edward Pearce'
__email__ = 'empearce1@sheffield.ac.uk'
__status__ = 'Development'
class PartitionExt(Partition):
r"""Extends the `Partition` class in SageMath with the following methods:
* G_colour_tableau(self, r, b=-1) - Returns tableau of `self` with cells coloured by $(i,j) \mapsto i + bj \ (\mathrm{mod}\ r)$.
* G_colour_count(self, r, b=-1) - Counts the number of cells in `self` of each colour under the $(r,b)$-colouring.
* G_weighted_hook_lengths(self, r, b=-1) - Returns tableau of `self` with cells numbered according to the formula
$$\ell(\square) - b(a(\square) + 1) \ (\mathrm{mod}\ r).$$
* is_G_core(self, r, b=-1) - Checks whether `self` is a G-core with respect to the $(r,b)$-action
* G_core(self, r, b=-1) - Returns the G-core partition of `self` with respect to the $(r,b)$-action
* G_quotient(self, r, b=-1) - Returns the G-quotient of `self` with respect to the $(r,b)$-action, an $r$-tuple of partitions
* G_abacus(self, r, b=-1) - Returns an $r$-tuple of path sequences {1:N, 0:E} corresponding to `self` and the $(r,b)$-action
* G_charges(self, r, b=-1) - Returns the charge coordinates of `self` with respect to the $(r,b)$-action, an $r$-tuple of integers
In the default case that only one argument `r` is passed, the action is of type $(r,-1) = (r,r-1)$ which is special linear and
yields the same result as the classical `core(r)` and `quotient(r)` methods.
"""
def __init__(self, mu):
"""
Initialize `self`.
"""
assert isinstance(mu, Partition)
self._list = mu._list
__repr__ = Partition._repr_list
def G_colour_tableau(self, r, b=-1):
r"""
Returns tableau of `self` with cells coloured according to the $(r,b)$-action on monomials over $\mathbb{C}[x,y]$.
Specifically, a cell $(i,j)$ is mapped to colour value $i + bj \ (\mathrm{mod}\ r)$.
"""
return [[(i + b * j) % r for j in range(self[i])] for i in range(len(self))]
def G_colour_count(self, r, b=-1):
r"""
Counts the number of cells in `self` of each colour under the $(r,b)$-colouring.
"""
counts = [0 for _ in range(r)]
for row in self.G_colour_tableau(r,b):
for cell_colour in row:
counts[cell_colour] += 1
assert sum(counts) == self.size()
return counts
def G_weighted_hook_lengths(self, r, b=-1):
r"""
Returns tableau of `self` with cells numbered according to the formula
$$\ell(\square) - b(a(\square) + 1) \ (\mathrm{mod}\ r).$$
In particular, a partition $p$ is called an $(r,b)$-core if none of the cells in this tableau are 0.
"""
return [[cell % r for cell in row] for row in self.upper_hook_lengths(-b)]
def is_G_core(self, r, b=-1):
r"""Checks whether `self` is a G-core with respect to the $(r,b)$-action. Returns: Bool
A partition is said to be an $(r,b)$-core if it has no cells satisfying the congruence equation
$$\ell(\square) - b(a(\square) + 1) \equiv 0 \ (\mathrm{mod}\ r).$$
Equivalently, a partition is said to be an $(r,b)$-core if it is its own $(r,b)$-core
(where the latter is defined as in `G_core()`).
"""
return not any(any((cell % r) == 0 for cell in row) for row in self.upper_hook_lengths(-b))
def G_abacus(self, r, b=-1, method='fast'):
r"""
Converts a partition to a finite representation of its $G$-abacus, where the $G$-action is of type $(r,b)$.
First, a sequence encoding the border path of the partition is calculated, with convention {1:N, 0:E} in English notation
Next, we separate path segments in the sequence onto $r$ different abacus wires according to their location in the lattice
$\mathbb{Z}^{2}$ and the lattice colouring defined by the $(r,b)$-action.
Returns: Length $r$ list of path sequences (themselves lists of '0's and '1's)
Note that every full path sequence starts with infinitely many '1's and ends with infinitely many '0's.
"""
if method == 'fast': # Reads abacus from minimal zero-one sequence, swapping '0' and '1' to ensure {1:N, 0:E} convention
seq = invert_zero_one(self.zero_one_sequence())
elif method == 'slow': # Dyck word is always longer than minimal zero-one sequence, so will take longer to read
seq = self.to_dyck_word()
abacus = [deque() for _ in range(r)]
wire_num = sum(seq) % r # counts number of '1's modulo r to find the starting wire index
for code in seq:
abacus[wire_num].append(code)
# The next wire to read from depends on the value of the current symbol
# Add b to the wire index if '0' was read, else subtract 1 if '1' was read, then reduce modulo r
wire_num = (wire_num + b * (1 - code) - code) % r
return abacus
def G_core(self, r, b=-1):
r"""
Calculates the G-core partition of `self` with respect to the $(r,b)$-action,
First, the G-charge coordinates of `self` are computed via the G-abacus. These are preserved by valid abacus moves.
Next, we implicitly slide beads on the G-abacus to remove any quotient component whilst preserving charges.
Finally, the modified abacus is converted back to a partition.
Returns: an instance of the PartitionExt class
"""
return self.from_G_charges_and_quotient(self.G_charges(r,b), quotient=None, r=r, b=b)
def G_quotient(self, r, b=-1, label_swap_xy=False):
r"""
Calculates the G-quotient of `self` with respect to the $(r,b)$-action,
First, the G-abacus of `self` is computed. Second, the path sequence of each abacus wire is converted back to a partition.
Note that the abacus uses the convention {1:N, 0:E} in English notation for partition border paths
Due to differences in conventions effectively swapping xy-coordinates for cell colouring (vs. content), the order of partitions
in the $(r,r-1)$-quotient ($b=-1$ special case) differs from the classical $r$-quotient by a reflection of indices.
This can be accounted for by setting the optional `label_swap_xy` keyword argument to `True`. A cell $(i,j)$ is mapped as
`Partition.content` -> $j - i$, whilst $(r,-1)$-colour -> $i - j (mod r)$ (as case of $(r,b)$-colour -> $i + bj (mod r)$).
Returns: an $r$-tuple of partitions
"""
# Sagemath uses the convention {1:E, 0:N} when reading partition from a path sequence, so we have to swap '0's and '1's
p_list = [Partition(zero_one=invert_zero_one(wire)) for wire in self.G_abacus(r,b)]
# Reflect the order of partitions in the $b=-1$ case `G_quotient` to account for differences in conventions for cell colouring
# for compatibility with `Partition.quotient`.
if label_swap_xy:
p_list = [p_list[0]] + p_list[:0:-1]
# Cast the list of partitions in the quotient as a `PartitionTuple` for compatibility with the `Partition.quotient` method
return PartitionTuple(p_list)
def G_charges(self, r, b=-1):
r"""
Calculates the charge coordinates of `self` with respect to the $(r,b)$-action, returning an $r$-tuple of integers.
The charge on each wire of the $(r,b)$-abacus of `self` describes the excess or deficit of electrons ('1' symbols)
relative to a fixed ground state - the $(r,b)$-abacus of the empty partition (the vacuum).
By construction, global charge (i.e. the sum of charge coordinates) is zero.
"""
abacus = self.G_abacus(r, b)
total_north_steps = sum(sum(wire) for wire in abacus)
# For reference to a fixed ground state, we calculate the number of north steps ('1' symbols) on each wire that
# we would expect if an abacus with the same number of total north steps was generated from the empty partition
expected = [(total_north_steps // r) + int(0 < i <= (total_north_steps % r)) for i in range(r)]
assert sum(expected) == total_north_steps
# The charge of a wire on the abacus is defined to be the difference in '1' symbols relative to the reference state
charges = [expected[i] - sum(wire) for i, wire in enumerate(abacus)]
# As the total number of '1' symbols should be equal in the true and reference abacus, the total excess/defecit is zero
assert sum(charges) == 0
return charges
@classmethod
def from_G_core_and_quotient(cls, core, quotient, r, b=-1):
r"""
Construct a partition from its generalized core and quotient decomposition with respect to the $(r,b)$-action.
This function checks that the input arguments are valid, in particular that `core` is indeed an $(r,b)$-core partition,
Then calculates the charge coordinates of `core` to pass to the function `from_G_charges_and_quotient`.
Inputs:
r, b - Describes G-action. Should have $0 < b < r$ coprime integers, though `b` need only be defined modulo `r`.
Default value for `b` is $-1 \equiv \ (\mathrm{mod}\ r)$ which describes special linear action.
core - must be an $(r,b)$-core partition, and must be an instance of PartitionExt
quotient - an $r$-tuple of Partition instances, or None. If None, returns `core` directly.
Returns:
An instance `mu` of PartitionExt such that `mu.G_core(r, b) == core` and `mu.G_quotient(r, b) == quotient`.
"""
assert isinstance(core, PartitionExt)
assert core.is_G_core(r, b) # Verifies whether the first argument is a $G$-core with respect to the $(r,b)$-action.
if quotient is None:
return core
else:
return cls.from_G_charges_and_quotient(core.G_charges(r, b), quotient, r, b)
@classmethod
def from_G_charges_and_quotient(cls, charges, quotient, r, b=-1):
r"""
Construct a partition from its $(r,b)$-charge coordinates and quotient decomposition.
First, convert the partitions in `quotient` into path sequences to construct a prelimary abacus.
Next, adjust the abacus according to `charges` to match the associated excess/deficit of '1' symbols in each finite wire segment
Then pass to the function `from_G_abacus` to flatten and read the path sequence before converting back to a partition.
Inputs:
r, b - Describes G-action. Should have $0 < b < r$ coprime integers, though `b` need only be defined modulo `r`.
Default value for `b` is $-1 \equiv \ r-1 (\mathrm{mod}\ r)$ which describes special linear action.
core - must be an $(r,b)$-core partition, and must be an instance of PartitionExt
quotient - an $r$-tuple of Partition instances, or None. If None, `quotient` is replaced by an $r$-tuple of empty partitions.
Returns:
An instance `mu` of PartitionExt such that `mu.G_charges(r, b) == charges` and `mu.G_quotient(r, b) == quotient`.
"""
# Input validation checks
assert len(charges) == r
assert sum(charges) == 0
if quotient is None:
# Initialize an empty abacus
# Full path sequences start with infinitely many '1's and end with infinitely many '0's, but these are all omitted.
n = 0
abacus = [deque() for _ in range(r)]
else:
assert len(quotient) == r # Check quotient has correct length
# Convert partitions in quotient to Dyck words of equal length
# Each wire begins with 2n symbols: n each of the symbols '0' and '1', describing the path sequence of the partition in `quotient`
n = max(len(mu.to_dyck_word()) for mu in quotient) // 2
abacus = [deque(mu.to_dyck_word(n)) for mu in quotient]
# Add a number of excess '1's to the left each wire according to the charge coordinates
# c_max - charges[i] describes the number of excess 1's on wire i
# In total, r * c_max many 1's are added since charges sum to zero
c_max = max(charges)
for i in range(r):
abacus[i].extendleft(1 for _ in range(c_max - charges[i]))
# Output validation checks
assert sum(len(wire) for wire in abacus) == r * (2*n + c_max) # Total number of symbols on whole abacus
assert sum(sum(wire) for wire in abacus) == r * (n + c_max) # Total number of '1's on whole abacus
return cls.from_G_abacus(abacus, r, b)
@classmethod
def from_G_abacus(cls, abacus, r=None, b=-1):
r"""
Construct a partition from a representation of its $(r,b)$-abacus. If parameter `r` is not given, can be inferred from `len(abacus)`.
Merges the wires of the abacus back into a single list of '0' and '1' symbols.
The resulting sequence encodes a partition boundary path by the rule {1:N, 0:E} as for Dyck paths/words.
After the G_abacus is flattened into a path sequence, the final conversion to a partition.
Returns:
An instance `mu` of PartitionExt such that `mu.G_abacus(r, b)` is isomorphic to `abacus` (i.e. describe same quotient and charges)
"""
abacus = [deque(wire) for wire in abacus] # Clean input to cast lists as deque instances to allow use of `popleft` method
if r is None: # Infer `r` from the number of wires in the abacus
r = len(abacus)
assert gcd(r,b) == 1 # Check that b is coprime to r to ensure the algorithm will terminate
path_seq = list()
north_steps_read = 0
total_north_steps = sum(sum(wire) for wire in abacus)
wire_num = total_north_steps % r # Starting wire index depends on the total number of '1's in the abacus
while north_steps_read < total_north_steps: # Loop should terminate after at most r*sum(len(wire) for wire in abacus) steps
# Read the next symbol from the current wire
if len(abacus[wire_num]) > 0:
# return and remove the leftmost item from the wire if not empty, this removes the need to track bead position
code = abacus[wire_num].popleft()
else: # To the right of each wire is an infinite sequence of '0's (used when finished reading finite part)
code = 0
# Add symbol to flattened path sequence
path_seq.append(code)
# Increase the number of '1's (north steps) read when appropriate (otherwise adding '0')
north_steps_read += code
# The next wire to read from depends on the value of the current symbol
# Add b to the wire index if '0' was read, else subtract 1 if '1' was read, then reduce ulo r
wire_num = (wire_num + b*(1 - code) - code) % r
# Sagemath uses the convention {1:E, 0:N} when reading partition from a path sequence, so we have to swap '0's and '1's
inverted_seq = invert_zero_one(path_seq)
return cls(Partition(zero_one=inverted_seq))
def invert_zero_one(sequence):
r"""Helper function to swap '0's and '1's in a binary sequence"""
return [1 - code for code in sequence]
|
{"hexsha": "f91a053fa833361787bd1251951cc18b6fa2c968", "size": 16822, "ext": "py", "lang": "Python", "max_stars_repo_path": "abacus_extension.py", "max_stars_repo_name": "edwardmpearce/pyparti", "max_stars_repo_head_hexsha": "951e78da7dfd6d4891a02b77ea67910e7435a17d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "abacus_extension.py", "max_issues_repo_name": "edwardmpearce/pyparti", "max_issues_repo_head_hexsha": "951e78da7dfd6d4891a02b77ea67910e7435a17d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "abacus_extension.py", "max_forks_repo_name": "edwardmpearce/pyparti", "max_forks_repo_head_hexsha": "951e78da7dfd6d4891a02b77ea67910e7435a17d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 53.7444089457, "max_line_length": 142, "alphanum_fraction": 0.6511710855, "include": true, "reason": "import sage,from sage", "num_tokens": 4304}
|
\documentclass[11pt]{article}
\usepackage[breakable]{tcolorbox}
\usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\else
\usepackage{fontspec}
\fi
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts  syntax from Markdown).
\usepackage{graphicx}
% Maintain compatibility with old templates. Remove in nbconvert 6.0
\let\Oldincludegraphics\includegraphics
% Ensure that by default, figures have no caption (until we provide a
% proper Figure object with a Caption API and a way to capture that
% in the conversion process - todo).
\usepackage{caption}
\DeclareCaptionFormat{nocaption}{}
\captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}
\usepackage{float}
\floatplacement{figure}{H} % forces figures to be placed at the correct location
\usepackage{xcolor} % Allow colors to be defined
\usepackage{enumerate} % Needed for markdown enumerations to work
\usepackage{geometry} % Used to adjust the document margins
\usepackage{amsmath} % Equations
\usepackage{amssymb} % Equations
\usepackage{textcomp} % defines textquotesingle
% Hack from http://tex.stackexchange.com/a/47451/13684:
\AtBeginDocument{%
\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
}
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
\usepackage{fancyvrb} % verbatim replacement that allows latex
\usepackage{grffile} % extends the file name processing of package graphics
% to support a larger range
\makeatletter % fix for old versions of grffile with XeLaTeX
\@ifpackagelater{grffile}{2019/11/01}
{
% Do nothing on new versions
}
{
\def\Gread@@xetex#1{%
\IfFileExists{"\Gin@base".bb}%
{\Gread@eps{\Gin@base.bb}}%
{\Gread@@xetex@aux#1}%
}
}
\makeatother
\usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
\adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}
% The hyperref package gives us a pdf with properly built
% internal navigation ('pdf bookmarks' for the table of contents,
% internal cross-reference links, web links for URLs, etc.)
\usepackage{hyperref}
% The default LaTeX title has an obnoxious amount of whitespace. By default,
% titling removes some of it. It also provides customization options.
\usepackage{titling}
\usepackage{longtable} % longtable support required by pandoc >1.10
\usepackage{booktabs} % table support for pandoc > 1.12.2
\usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
\usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
% normalem makes italics be italics, not underlines
\usepackage{mathrsfs}
% Colors for the hyperref package
\definecolor{urlcolor}{rgb}{0,.145,.698}
\definecolor{linkcolor}{rgb}{.71,0.21,0.01}
\definecolor{citecolor}{rgb}{.12,.54,.11}
% ANSI colors
\definecolor{ansi-black}{HTML}{3E424D}
\definecolor{ansi-black-intense}{HTML}{282C36}
\definecolor{ansi-red}{HTML}{E75C58}
\definecolor{ansi-red-intense}{HTML}{B22B31}
\definecolor{ansi-green}{HTML}{00A250}
\definecolor{ansi-green-intense}{HTML}{007427}
\definecolor{ansi-yellow}{HTML}{DDB62B}
\definecolor{ansi-yellow-intense}{HTML}{B27D12}
\definecolor{ansi-blue}{HTML}{208FFB}
\definecolor{ansi-blue-intense}{HTML}{0065CA}
\definecolor{ansi-magenta}{HTML}{D160C4}
\definecolor{ansi-magenta-intense}{HTML}{A03196}
\definecolor{ansi-cyan}{HTML}{60C6C8}
\definecolor{ansi-cyan-intense}{HTML}{258F8F}
\definecolor{ansi-white}{HTML}{C5C1B4}
\definecolor{ansi-white-intense}{HTML}{A1A6B2}
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
% common color for the border for error outputs.
\definecolor{outerrorbackground}{HTML}{FFDFDF}
% commands and environments needed by pandoc snippets
% extracted from the output of `pandoc -s`
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
% Additional commands for more recent versions of Pandoc
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
\newcommand{\ImportTok}[1]{{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
\newcommand{\BuiltInTok}[1]{{#1}}
\newcommand{\ExtensionTok}[1]{{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
% Define a nice break command that doesn't care if a line doesn't already
% exist.
\def\br{\hspace*{\fill} \\* }
% Math Jax compatibility definitions
\def\gt{>}
\def\lt{<}
\let\Oldtex\TeX
\let\Oldlatex\LaTeX
\renewcommand{\TeX}{\textrm{\Oldtex}}
\renewcommand{\LaTeX}{\textrm{\Oldlatex}}
% Document parameters
% Document title
\title{Data Analysis procedure}
\date{}
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
\let\PY@ul=\relax \let\PY@tc=\relax%
\let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
\PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
\PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}
\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{-\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother
% For linebreaks inside Verbatim environment from package fancyvrb.
\makeatletter
\newbox\Wrappedcontinuationbox
\newbox\Wrappedvisiblespacebox
\newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}}
\newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
\newcommand*\Wrappedcontinuationindent {3ex }
\newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox}
% Take advantage of the already applied Pygments mark-up to insert
% potential linebreaks for TeX processing.
% {, <, #, %, $, ' and ": go to next line.
% _, }, ^, &, >, - and ~: stay at end of broken line.
% Use of \textquotesingle for straight quote.
\newcommand*\Wrappedbreaksatspecials {%
\def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}%
\def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}%
\def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}%
\def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}%
\def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}%
\def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}%
\def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}%
\def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}%
\def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}%
\def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}%
\def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}%
\def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}%
\def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}%
\def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}%
}
% Some characters . , ; ? ! / are not pygmentized.
% This macro makes them "active" and they will insert potential linebreaks
\newcommand*\Wrappedbreaksatpunct {%
\lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}%
\lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}%
\lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}%
\lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}%
\lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}%
\lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}%
\lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}%
\catcode`\.\active
\catcode`\,\active
\catcode`\;\active
\catcode`\:\active
\catcode`\?\active
\catcode`\!\active
\catcode`\/\active
\lccode`\~`\~
}
\makeatother
\let\OriginalVerbatim=\Verbatim
\makeatletter
\renewcommand{\Verbatim}[1][1]{%
%\parskip\z@skip
\sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
\sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
\def\FancyVerbFormatLine ##1{\hsize\linewidth
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
\doublehyphendemerits\z@\finalhyphendemerits\z@
\strut ##1\strut}%
}%
% If the linebreak is at a space, the latter will be displayed as visible
% space at end of first line, and a continuation symbol starts next line.
% Stretch/shrink are however usually zero for typewriter font.
\def\FV@Space {%
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
\discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
{\kern\fontdimen2\font}%
}%
% Allow breaks at special characters using \PYG... macros.
\Wrappedbreaksatspecials
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
\OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
}
\makeatother
% Exact colors from NB
\definecolor{incolor}{HTML}{303F9F}
\definecolor{outcolor}{HTML}{D84315}
\definecolor{cellborder}{HTML}{CFCFCF}
\definecolor{cellbackground}{HTML}{F7F7F7}
% prompt
\makeatletter
\newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
\makeatother
\newcommand{\prompt}[4]{
{\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
}
% Prevent overflowing lines due to hard-to-break entities
\sloppy
% Setup hyperref package
\hypersetup{
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=urlcolor,
linkcolor=linkcolor,
citecolor=citecolor,
}
% Slightly bigger margins than the latex defaults
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\begin{document}
\maketitle
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{o}{\PYZpc{}}\PY{k}{load\PYZus{}ext} lab\PYZus{}black
\PY{c+c1}{\PYZsh{} Import important tools}
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
\PY{k+kn}{import} \PY{n+nn}{matplotlib} \PY{k}{as} \PY{n+nn}{mpl}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{io} \PY{k+kn}{import} \PY{n}{loadmat}\PY{p}{,} \PY{n}{savemat}
\PY{k+kn}{from} \PY{n+nn}{mpl\PYZus{}toolkits}\PY{n+nn}{.}\PY{n+nn}{mplot3d} \PY{k+kn}{import} \PY{n}{Axes3D}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{optimize} \PY{k+kn}{import} \PY{n}{curve\PYZus{}fit}\PY{p}{,} \PY{n}{minimize}\PY{p}{,} \PY{n}{least\PYZus{}squares}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{integrate} \PY{k+kn}{import} \PY{n}{trapz}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{stats} \PY{k+kn}{import} \PY{n}{norm}\PY{p}{,} \PY{n}{kurtosis}
\PY{k+kn}{from} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{ticker} \PY{k+kn}{import} \PY{n}{ScalarFormatter}
\PY{k+kn}{from} \PY{n+nn}{matplotlib} \PY{k+kn}{import} \PY{n}{rc}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{mpl}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{xtick.direction}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{in}\PY{l+s+s2}{\PYZdq{}}
\PY{n}{mpl}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ytick.direction}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{in}\PY{l+s+s2}{\PYZdq{}}
\PY{n}{mpl}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{lines.markeredgecolor}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}
\PY{n}{mpl}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{lines.markeredgewidth}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{mpl}\PY{o}{.}\PY{n}{rcParams}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{figure.dpi}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{130}
\PY{n}{rc}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{font}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{family}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{serif}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{rc}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{text}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{usetex}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{rc}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{xtick}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{labelsize}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZhy{}small}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{rc}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ytick}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{labelsize}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZhy{}small}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{cm2inch}\PY{p}{(}\PY{n}{value}\PY{p}{)}\PY{p}{:}
\PY{k}{return} \PY{n}{value} \PY{o}{/} \PY{l+m+mf}{2.54}
\end{Verbatim}
\end{tcolorbox}
We load the data
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{raw\PYZus{}data} \PY{o}{=} \PY{n}{loadmat}\PY{p}{(}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{fit\PYZus{}result\PYZus{}dur\PYZus{}27052020\PYZus{}n\PYZus{}r\PYZus{}fix\PYZus{}0p0513\PYZus{}wav\PYZus{}532\PYZus{}r\PYZus{}1p516\PYZus{}n\PYZus{}1.597.mat}\PY{l+s+s2}{\PYZdq{}}
\PY{p}{)}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{data}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{3}\PY{p}{]}
\PY{n}{r} \PY{o}{=} \PY{l+m+mf}{1.516} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{n\PYZus{}part} \PY{o}{=} \PY{l+m+mf}{1.597}
\PY{n}{fps} \PY{o}{=} \PY{l+m+mi}{60}
\PY{n}{time} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{shape}\PY{p}{(}\PY{n}{raw\PYZus{}data}\PY{p}{)}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{n}{fps}
\PY{n}{dataset} \PY{o}{=} \PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{r}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{r}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{n}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{n\PYZus{}part}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{fps}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{fps}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{time}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{time}
\end{Verbatim}
\end{tcolorbox}
\hypertarget{data-exploration}{%
\section{Data exploration}\label{data-exploration}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} We put everything in microns}
\PY{n}{raw\PYZus{}data\PYZus{}m} \PY{o}{=} \PY{n}{raw\PYZus{}data}
\PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{3}\PY{p}{]} \PY{o}{=} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{3}\PY{p}{]} \PY{o}{*} \PY{l+m+mf}{0.0513}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time} \PY{o}{/} \PY{n}{fps}\PY{p}{,} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{]}\PY{p}{)}
\PY{n}{x} \PY{o}{=} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}
\PY{n}{y} \PY{o}{=} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{z} \PY{o}{=} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{]}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}t\PYZdl{} (minutes)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}z\PYZdl{} (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_6_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time} \PY{o}{/} \PY{n}{fps}\PY{p}{,} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time} \PY{o}{/} \PY{n}{fps}\PY{p}{,} \PY{n}{raw\PYZus{}data\PYZus{}m}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{y}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}t\PYZdl{} (minutes)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}x\PYZdl{} (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_7_0.png}
\end{center}
{ \hspace*{\fill} \\}
\hypertarget{msd}{%
\section{MSD}\label{msd}}
We compute the MSD using the formula:
\begin{equation}
\langle\Delta r_i(t)^2 \rangle_t = \langle[r_i(t+\Delta t) - r_i(t)]^2\rangle_t\ .
\label{MSDdef}
\end{equation}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{6}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{MSD}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{t}\PY{p}{)}\PY{p}{:}
\PY{n}{MSD} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{t}\PY{p}{)}\PY{p}{)}
\PY{k}{for} \PY{n}{n}\PY{p}{,} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{t}\PY{p}{)}\PY{p}{:}
\PY{n}{MSD}\PY{p}{[}\PY{n}{n}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{nanmean}\PY{p}{(}\PY{p}{(}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{x}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{k}{return} \PY{n}{MSD}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{t} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}
\PY{p}{[}
\PY{o}{*}\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}\PY{p}{,}
\PY{o}{*}\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{)}\PY{p}{,}
\PY{o}{*}\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{)}\PY{p}{,}
\PY{o}{*}\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{40000}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}\PY{p}{,}
\PY{p}{]}
\PY{p}{)}
\PY{n}{MSD\PYZus{}x} \PY{o}{=} \PY{n}{MSD}\PY{p}{(}\PY{n}{x} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{t}\PY{p}{)} \PY{c+c1}{\PYZsh{} m² conversion}
\PY{n}{MSD\PYZus{}y} \PY{o}{=} \PY{n}{MSD}\PY{p}{(}\PY{n}{y} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{t}\PY{p}{)}
\PY{n}{MSD\PYZus{}z} \PY{o}{=} \PY{n}{MSD}\PY{p}{(}\PY{n}{z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{t}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{loglog}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}x}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}x\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}y}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}y\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}z}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}z\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{m\PYZca{}2\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta t\PYZdl{} (s)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}x\PYZus{}tot}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}x}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}y\PYZus{}tot}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}y}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}z\PYZus{}tot}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}z}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}time\PYZus{}tot}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_10_0.png}
\end{center}
{ \hspace*{\fill} \\}
We fit the short time MSD with and average diffusion coefficient such
as:
\begin{equation}
\langle\Delta r_i(t)^2 \rangle_t = 2 \langle D_i \rangle \Delta t\ ,
\label{averagediff}
\end{equation}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{8}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{Do} \PY{o}{=} \PY{l+m+mf}{4e\PYZhy{}21} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{l+m+mf}{0.001} \PY{o}{*} \PY{n}{r}\PY{p}{)}
\PY{n}{f} \PY{o}{=} \PY{k}{lambda} \PY{n}{x}\PY{p}{,} \PY{n}{a}\PY{p}{,} \PY{n}{noiselevel}\PY{p}{:} \PY{l+m+mi}{2} \PY{o}{*} \PY{n}{Do} \PY{o}{*} \PY{n}{a} \PY{o}{*} \PY{n}{x} \PY{o}{+} \PY{p}{(}\PY{n}{noiselevel} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}
\PY{n}{popt\PYZus{}1}\PY{p}{,} \PY{n}{pcov\PYZus{}1} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{f}\PY{p}{,} \PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{30}\PY{p}{]}\PY{p}{)}
\PY{n}{popt\PYZus{}2}\PY{p}{,} \PY{n}{pcov\PYZus{}1} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{f}\PY{p}{,} \PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}y}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{30}\PY{p}{]}\PY{p}{)}
\PY{n}{popt\PYZus{}3}\PY{p}{,} \PY{n}{pcov\PYZus{}1} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{f}\PY{p}{,} \PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{30}\PY{p}{]}\PY{p}{)}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}MSD\PYZus{}fit}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}y}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}y}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{MSD\PYZus{}z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{l+m+mi}{5}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
C:\textbackslash{}Users\textbackslash{}m.lavaud\textbackslash{}.conda\textbackslash{}envs\textbackslash{}analyse\textbackslash{}lib\textbackslash{}site-
packages\textbackslash{}scipy\textbackslash{}optimize\textbackslash{}minpack.py:828: OptimizeWarning: Covariance of the
parameters could not be estimated
warnings.warn('Covariance of the parameters could not be estimated',
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{9}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nb}{print}\PY{p}{(}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{We measure a reduced mean diffusion coefficient of }\PY{l+s+si}{\PYZob{}:.3f\PYZcb{}}\PY{l+s+s2}{ for the perpendicular motion and of }\PY{l+s+si}{\PYZob{}:.3f\PYZcb{}}\PY{l+s+s2}{ for the parallel motion}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}
\PY{p}{(}\PY{n}{popt\PYZus{}1}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+} \PY{n}{popt\PYZus{}2}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{,} \PY{n}{popt\PYZus{}3}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{p}{)}
\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
We measure a reduced mean diffusion coefficient of 0.522 for the perpendicular
motion and of 0.243 for the parallel motion
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{10}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{loglog}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}x}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}x\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}y}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}y\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}z}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}z\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{m\PYZca{}2\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta t\PYZdl{} (s)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{tt} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{1e\PYZhy{}2}\PY{p}{,} \PY{l+m+mf}{1e3}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{n}{f}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{o}{*}\PY{n}{popt\PYZus{}1}\PY{p}{)}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{n}{f}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{o}{*}\PY{n}{popt\PYZus{}3}\PY{p}{)}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlim}\PY{p}{(}\PY{p}{(}\PY{l+m+mf}{1e\PYZhy{}2}\PY{p}{,} \PY{l+m+mf}{1e3}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{10}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
<matplotlib.legend.Legend at 0x27a80c0b700>
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_14_1.png}
\end{center}
{ \hspace*{\fill} \\}
\hypertarget{displacement-distributions}{%
\section{Displacement distributions}\label{displacement-distributions}}
\hypertarget{delta-x-distributions}{%
\subsection{\texorpdfstring{\(\Delta x\)
distributions}{\textbackslash Delta x distributions}}\label{delta-x-distributions}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{11}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{pdf}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{10}\PY{p}{,} \PY{n}{density}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}\PY{p}{:}
\PY{l+s+sd}{\PYZdq{}\PYZdq{}\PYZdq{}}
\PY{l+s+sd}{ function to automatize the computations of experimental probability density functions.}
\PY{l+s+sd}{ \PYZdq{}\PYZdq{}\PYZdq{}}
\PY{n}{pdf}\PY{p}{,} \PY{n}{bins\PYZus{}edge} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{histogram}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{n}{bins}\PY{p}{,} \PY{n}{density}\PY{o}{=}\PY{n}{density}\PY{p}{)}
\PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{p}{(}\PY{n}{bins\PYZus{}edge}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{+} \PY{n}{bins\PYZus{}edge}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}
\PY{k}{return} \PY{n}{pdf}\PY{p}{,} \PY{n}{bins\PYZus{}center}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{12}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{I} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{50}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{500}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{2000}\PY{p}{]}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{I}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{x}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{50}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{hist}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{12}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta x\$ [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_17_1.png}
\end{center}
{ \hspace*{\fill} \\}
If we now normalize by the standard deviation
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{13}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{gauss\PYZus{}function}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{a}\PY{p}{,} \PY{n}{x0}\PY{p}{,} \PY{n}{sigma}\PY{p}{)}\PY{p}{:}
\PY{k}{return} \PY{n}{a} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{p}{(}\PY{n}{x} \PY{o}{\PYZhy{}} \PY{n}{x0}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{sigma} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{14}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{for} \PY{n}{n}\PY{p}{,} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{I}\PY{p}{)}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{x}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{Dezs} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{l+m+mi}{2} \PY{o}{*} \PY{n}{Do} \PY{o}{*} \PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{30}\PY{p}{)}
\PY{c+c1}{\PYZsh{} if i == I[0]:}
\PY{c+c1}{\PYZsh{} popt, pcov = curve\PYZus{}fit(gauss\PYZus{}function, bins\PYZus{}center/np.max(bins\PYZus{}center), hist, p0 = [1, np.mean(hist), np.std(hist)])}
\PY{c+c1}{\PYZsh{} plt.plot(bins\PYZus{}center/np.max(bins\PYZus{}center), gauss\PYZus{}function(bins\PYZus{}center, *popt), label = \PYZdq{}fit at t = \PYZob{}:.2f\PYZcb{} s\PYZdq{}.format(time[i]))}
\PY{c+c1}{\PYZsh{} plt.plot(bins\PYZus{}center/np.max(bins\PYZus{}center), hist, \PYZdq{}x\PYZdq{},label = \PYZdq{} t = \PYZob{}:.2f\PYZcb{} s\PYZdq{}.format(time[i]),color = \PYZdq{}tab:blue\PYZdq{})}
\PY{c+c1}{\PYZsh{} continue}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}
\PY{n}{bins\PYZus{}center} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{)}\PY{p}{,}
\PY{n}{hist}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
\PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ \PYZdl{}Delta\PYZdl{}t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{,}
\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{normalized \PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{14}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, 'normalized \$\textbackslash{}\textbackslash{}Delta x\$ [a.u.]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_20_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{15}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{p}{(}\PY{l+m+mf}{3.5e\PYZhy{}22}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{/} \PY{l+m+mi}{3}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{15}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
7.047298732064899e-08
\end{Verbatim}
\end{tcolorbox}
We can see a clear change but we would need to average on different
trajectectories to have consitant results.
\hypertarget{delta-z-distributions}{%
\subsection{\texorpdfstring{\(\Delta z\)
distributions}{\textbackslash Delta z distributions}}\label{delta-z-distributions}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{16}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{I} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{50}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{500}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{2000}\PY{p}{,} \PY{l+m+mi}{5000}\PY{p}{,} \PY{l+m+mi}{10000}\PY{p}{]}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{I}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{z}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{50}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{hist}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{16}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta x\$ [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_24_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{17}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{I}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{z}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{Dezs} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{nanstd}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{30}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{hist}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{17}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta x\$ [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_25_1.png}
\end{center}
{ \hspace*{\fill} \\}
\hypertarget{short-time-distributions}{%
\subsubsection{Short time
distributions}\label{short-time-distributions}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{18}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{I} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{5}\PY{p}{,} \PY{l+m+mi}{6}\PY{p}{,} \PY{l+m+mi}{9}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{]}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{I}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{z}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{Dezs} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{100}\PY{p}{)}
\PY{k}{if} \PY{n}{i} \PY{o}{==} \PY{n}{I}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{:}
\PY{n}{popt}\PY{p}{,} \PY{n}{pcov} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}
\PY{n}{gauss\PYZus{}function}\PY{p}{,} \PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{hist}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{hist}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{n}{hist}\PY{p}{)}\PY{p}{]}
\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{gauss\PYZus{}function}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{o}{*}\PY{n}{popt}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}
\PY{n}{bins\PYZus{}center}\PY{p}{,}
\PY{n}{hist}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
\PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{,}
\PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:blue}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
\PY{p}{)}
\PY{k}{continue}
\PY{n}{plt}\PY{o}{.}\PY{n}{semilogy}\PY{p}{(}\PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{hist}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta r\PYZus{}z)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta r\PYZus{}z\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{axes} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{gca}\PY{p}{(}\PY{p}{)}
\PY{n}{axes}\PY{o}{.}\PY{n}{set\PYZus{}ylim}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{1e\PYZhy{}5}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{18}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
(1e-05, 1)
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_27_1.png}
\end{center}
{ \hspace*{\fill} \\}
The non-Gaussianity is due to the hindered mobility. Taking into account
the hindered mobility the PDF of displacement writes:
\begin{equation} P(\Delta r_i , \Delta t) = \int_0 ^\infty \mathrm{d}DP(D_i) \frac{1}{\sqrt{4 \pi D_i \Delta t}} \exp\left[ \frac{-\Delta_i r_i ^2}{4D_i\Delta t} \right]~. \end{equation}
This non-Gaussianity can be fitted as done at the end of this appendix
and shown in the manuscript.
\hypertarget{long-time-distributions}{%
\subsection{Long time distributions}\label{long-time-distributions}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{19}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{I} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{2000}\PY{p}{,} \PY{l+m+mi}{5000}\PY{p}{,} \PY{l+m+mi}{10000}\PY{p}{]}
\PY{n}{color\PYZus{}long\PYZus{}time} \PY{o}{=} \PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:gray}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:olive}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:cyan}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\PY{k}{for} \PY{n}{n}\PY{p}{,} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{I}\PY{p}{)}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{z}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{z}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{10}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{semilogy}\PY{p}{(}
\PY{n}{bins\PYZus{}center}\PY{p}{,}
\PY{n}{hist}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
\PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ \PYZdl{}t = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{\PYZdl{} s}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{)}\PY{p}{,}
\PY{n}{color}\PY{o}{=}\PY{n}{color\PYZus{}long\PYZus{}time}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{p}{,}
\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta r\PYZus{}z)\PYZdl{} [a.u.]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta r\PYZus{}z\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{19}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta r\_z\$ [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_30_1.png}
\end{center}
{ \hspace*{\fill} \\}
Indeed at long time it becomes exponential and it's no longer dependent
on \(\Delta t\) At very long time intervals \(\Delta t\) each position
measurement can be seen as random measurement on the Boltzmann
distribution. Thus, one can write the probability distribution as a
convolution of two PDF:
\begin{equation} P(\Delta z) = \int ^ \infty _{- \infty} dz P_B (z)P_B (z + \Delta z), \end{equation}
with :
\begin{equation} P_B(z) = Ae^{\left(Bexp\left(-\frac{z}{l_d}\right) - \frac{z}{l_b}\right)} \end{equation}
Also, \(P_B(z < 0)\) giving at long time step :
\begin{equation} P(\Delta z) = A'exp \left[Bexp\left[-\frac{z}{l_d}\right] (1 + exp[- \frac{\Delta z}{ l_d}]) - \frac{ 2z + \Delta z}{l_b} \right] \end{equation}
\hypertarget{analysis-of-pdf-of-the-delta-z-at-large-time-step}{%
\subsection{\texorpdfstring{Analysis of pdf of the \(\Delta z\) at large
time
step}{Analysis of pdf of the \textbackslash Delta z at large time step}}\label{analysis-of-pdf-of-the-delta-z-at-large-time-step}}
To have a better measurement we average the PDF of displacement
\(\Delta r_z\) over different time-step \(\Delta t\) . But, first of
all, we need to get rid of the drifts at long time. We do that by taking
a moving minimum.
\hypertarget{dedrifting-the-z-trajectory}{%
\subsection{Dedrifting the z
trajectory}\label{dedrifting-the-z-trajectory}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{20}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{movmin}\PY{p}{(}\PY{n}{datas}\PY{p}{,} \PY{n}{k}\PY{p}{)}\PY{p}{:}
\PY{n}{result} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty\PYZus{}like}\PY{p}{(}\PY{n}{datas}\PY{p}{)}
\PY{n}{start\PYZus{}pt} \PY{o}{=} \PY{l+m+mi}{0}
\PY{n}{end\PYZus{}pt} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{ceil}\PY{p}{(}\PY{n}{k} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}
\PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{datas}\PY{p}{)}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{i} \PY{o}{\PYZlt{}} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{ceil}\PY{p}{(}\PY{n}{k} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{:}
\PY{n}{start\PYZus{}pt} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{if} \PY{n}{i} \PY{o}{\PYZgt{}} \PY{n+nb}{len}\PY{p}{(}\PY{n}{datas}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{ceil}\PY{p}{(}\PY{n}{k} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{p}{:}
\PY{n}{end\PYZus{}pt} \PY{o}{=} \PY{n+nb}{len}\PY{p}{(}\PY{n}{datas}\PY{p}{)}
\PY{n}{result}\PY{p}{[}\PY{n}{i}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{datas}\PY{p}{[}\PY{n}{start\PYZus{}pt}\PY{p}{:}\PY{n}{end\PYZus{}pt}\PY{p}{]}\PY{p}{)}
\PY{n}{start\PYZus{}pt} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
\PY{n}{end\PYZus{}pt} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
\PY{k}{return} \PY{n}{result}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{21}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{z\PYZus{}dedrift} \PY{o}{=} \PY{n}{z} \PY{o}{\PYZhy{}} \PY{n}{movmin}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{l+m+mi}{10000}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{22}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Fig for comparing the two}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{,} \PY{n}{z} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{min}\PY{p}{(}\PY{n}{z}\PY{p}{)}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{raw}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{time}\PY{p}{,} \PY{n}{z\PYZus{}dedrift}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{dedrifted}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{t [s]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{22}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0, 0.5, 'z [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_36_1.png}
\end{center}
{ \hspace*{\fill} \\}
\hypertarget{measuring-pdf-at-large-delta-t-with-the-dedrifted-trajectory-and-analysing-it}{%
\subsubsection{\texorpdfstring{Measuring pdf at large \(\Delta t\) with
the dedrifted trajectory and analysing
it}{Measuring pdf at large \textbackslash Delta t with the dedrifted trajectory and analysing it}}\label{measuring-pdf-at-large-delta-t-with-the-dedrifted-trajectory-and-analysing-it}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{23}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{t\PYZus{}start} \PY{o}{=} \PY{l+m+mi}{25}
\PY{n}{t\PYZus{}end} \PY{o}{=} \PY{l+m+mi}{30}
\PY{n}{I} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{n}{t\PYZus{}start} \PY{o}{*} \PY{n}{fps}\PY{p}{,} \PY{n}{t\PYZus{}end} \PY{o}{*} \PY{n}{fps}\PY{p}{)}
\PY{n}{bins} \PY{o}{=} \PY{l+m+mi}{50}
\PY{n}{hists} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{(}\PY{n}{bins}\PY{p}{,} \PY{n+nb}{len}\PY{p}{(}\PY{n}{I}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{n}{bins\PYZus{}centers} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{p}{(}\PY{n}{bins}\PY{p}{,} \PY{n+nb}{len}\PY{p}{(}\PY{n}{I}\PY{p}{)}\PY{p}{)}\PY{p}{)}
\PY{k}{for} \PY{n}{n}\PY{p}{,} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{I}\PY{p}{)}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{z\PYZus{}dedrift}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{z\PYZus{}dedrift}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{n}{bins}\PY{p}{)}
\PY{n}{hists}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{n}{n}\PY{p}{]} \PY{o}{=} \PY{n}{hist}
\PY{n}{bins\PYZus{}centers}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{n}{n}\PY{p}{]} \PY{o}{=} \PY{n}{bins\PYZus{}center}
\PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{hists}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{bins\PYZus{}centers}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{err\PYZus{}long\PYZus{}t} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{n}{hists}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
\PY{n}{err\PYZus{}bins\PYZus{}centers} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{std}\PY{p}{(}\PY{n}{bins\PYZus{}centers}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{24}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{fill\PYZus{}between}\PY{p}{(}
\PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{\PYZhy{}} \PY{n}{err\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{+} \PY{n}{err\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{alpha}\PY{o}{=}\PY{l+m+mf}{0.3}
\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x)\PYZdl{} (\PYZdl{}m\PYZca{}}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZhy{}1\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta x\PYZdl{} (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{24}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta x\$ (\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$)')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_39_1.png}
\end{center}
{ \hspace*{\fill} \\}
We are now going to code the function
\begin{equation} P(\Delta z) = \int ^ \infty _{- \infty}A'exp \left[Bexp\left[-\frac{z}{l_d}\right] (1 + exp[- \frac{\Delta z}{ l_d}]) - \frac{ 2z + \Delta z}{l_b} \right] \end{equation}
Noting that coding the form :
\begin{equation} P(\Delta z) = \int ^ \infty _{- \infty} dz P_B (z)P_B (z + \Delta z), \end{equation}
Will be easier and \(P_B\) will be reused later on. Also since
\(P_B(z < 0) = 0\) :
\begin{equation} P(\Delta z) = \int ^ \infty _{0} dz P_B (z)P_B (z + \Delta z), \end{equation}
with :
\begin{equation} P_B(z) = Ae^{\left(Bexp\left(-\frac{z}{l_d}\right) - \frac{z}{l_b}\right)} \end{equation}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{25}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{P\PYZus{}b}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{n}{P\PYZus{}b} \PY{o}{=} \PY{n}{A} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{B} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{z} \PY{o}{/} \PY{p}{(}\PY{n}{ld}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{z} \PY{o}{/} \PY{n}{lb}\PY{p}{)}
\PY{n}{P\PYZus{}b}\PY{p}{[}\PY{n}{z} \PY{o}{\PYZlt{}} \PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{return} \PY{n}{P\PYZus{}b}
\PY{k}{def} \PY{n+nf}{dPdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{DZ}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{k}{return} \PY{n}{P\PYZus{}b}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)} \PY{o}{*} \PY{n}{P\PYZus{}b}\PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{DZ}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{P\PYZus{}computation}\PY{p}{(}\PY{n}{DZ}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{n}{z} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mf}{20e\PYZhy{}6}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}
\PY{n}{dP} \PY{o}{=} \PY{n}{dPdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{DZ}\PY{p}{,} \PY{n}{A}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{n}{P} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}\PY{n}{dP}\PY{p}{,} \PY{n}{z}\PY{p}{)}
\PY{k}{return} \PY{n}{P}
\PY{k}{def} \PY{n+nf}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{DZ}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n+nb}{type}\PY{p}{(}\PY{n}{DZ}\PY{p}{)} \PY{o}{==} \PY{n+nb}{float}\PY{p}{:}
\PY{k}{return} \PY{n}{P\PYZus{}computation}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{n}{pdf} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[}\PY{n}{P\PYZus{}computation}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{,} \PY{n}{lb} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{)} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{DZ}\PY{p}{]}\PY{p}{)}
\PY{c+c1}{\PYZsh{} normalisation of the PDF to not use A}
\PY{n}{A} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}\PY{n}{pdf}\PY{p}{,} \PY{n}{DZ} \PY{o}{*} \PY{l+m+mf}{1e6}\PY{p}{)}
\PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[}\PY{n}{P\PYZus{}computation}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{,} \PY{n}{lb} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{)} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{DZ}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{n}{A}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{26}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{A} \PY{o}{=} \PY{l+m+mf}{0.14e8}
\PY{n}{B} \PY{o}{=} \PY{l+m+mi}{4}
\PY{n}{ld} \PY{o}{=} \PY{l+m+mi}{70}
\PY{n}{lb} \PY{o}{=} \PY{l+m+mi}{500}
\PY{n}{p1} \PY{o}{=} \PY{p}{[}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}
\PY{c+c1}{\PYZsh{} Normalisation fo the pdf}
\PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{=} \PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{/} \PY{n}{trapz}\PY{p}{(}\PY{n}{pdf\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t}\PY{p}{)}
\PY{n}{popt}\PY{p}{,} \PY{n}{pcov} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{Pdeltaz\PYZus{}long}\PY{p}{,} \PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{n}{p1}\PY{p}{)}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{pdf\PYZus{}long\PYZus{}t}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
<ipython-input-25-d08630fe76fc>:2: RuntimeWarning: overflow encountered in exp
P\_b = A * np.exp(-B * np.exp(-z / (ld)) - z / lb)
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{27}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{A} \PY{o}{=} \PY{l+m+mf}{0.14e8}
\PY{n}{B} \PY{o}{=} \PY{l+m+mi}{400}
\PY{n}{ld} \PY{o}{=} \PY{l+m+mi}{70}
\PY{n}{lb} \PY{o}{=} \PY{l+m+mi}{500}
\PY{n}{p0} \PY{o}{=} \PY{p}{[}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}
\PY{n}{plt}\PY{o}{.}\PY{n}{semilogy}\PY{p}{(}\PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P\PYZus{}z(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta r\PYZus{}z)\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{fill\PYZus{}between}\PY{p}{(}
\PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{\PYZhy{}} \PY{n}{err\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{pdf\PYZus{}long\PYZus{}t} \PY{o}{+} \PY{n}{err\PYZus{}long\PYZus{}t}\PY{p}{,} \PY{n}{alpha}\PY{o}{=}\PY{l+m+mf}{0.3}
\PY{p}{)}
\PY{n}{zz} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{4}\PY{p}{,} \PY{l+m+mi}{4}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{zz}\PY{p}{,} \PY{n}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{zz} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{o}{*}\PY{n}{popt}\PY{p}{)}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{fit}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlim}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{4}\PY{p}{,} \PY{l+m+mi}{4}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta z)\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta z\PYZdl{} [\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{}]}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{27}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta z\$ [\$\textbackslash{}\textbackslash{}mathrm\{\textbackslash{}\textbackslash{}mu m\}\$]')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_43_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{28}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{We measure, B = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{, ld = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ nm, lb = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ nm}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{o}{*}\PY{n}{popt}\PY{p}{)}\PY{p}{)}
\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb} \PY{o}{=} \PY{n}{popt}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
We measure, B = 20.71, ld = 71.84 nm, lb = 504.78 nm
\end{Verbatim}
\hypertarget{analyse-of-the-msd-z-plateau}{%
\subsection{Analyse of the MSD z
plateau}\label{analyse-of-the-msd-z-plateau}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{29}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{t} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{concatenate}\PY{p}{(}
\PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}\PY{p}{,}
\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{10}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{10}\PY{p}{)}\PY{p}{,}
\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{100}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{100}\PY{p}{)}\PY{p}{,}
\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{1000}\PY{p}{,} \PY{l+m+mi}{10000}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}\PY{p}{,}
\PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{10000}\PY{p}{,} \PY{l+m+mi}{50000}\PY{p}{,} \PY{l+m+mi}{5000}\PY{p}{)}\PY{p}{,}
\PY{p}{)}
\PY{p}{)}
\PY{n}{MSD\PYZus{}z\PYZus{}dedrift} \PY{o}{=} \PY{n}{MSD}\PY{p}{(}\PY{n}{z\PYZus{}dedrift} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{t}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{loglog}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}z\PYZus{}dedrift}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSDz undrifted}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:green}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD (m\PYZdl{}\PYZca{}2\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta\PYZdl{}t (s)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{29}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta\$t (s)')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_46_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{30}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plateau} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{MSD\PYZus{}z\PYZus{}dedrift}\PY{p}{[}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]} \PY{o}{\PYZgt{}} \PY{l+m+mf}{1e2}\PY{p}{]}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{31}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{loglog}\PY{p}{(}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]}\PY{p}{,} \PY{n}{MSD\PYZus{}z\PYZus{}dedrift}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{label}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}z\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{tab:green}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{p}{[}\PY{n}{plateau}\PY{p}{]} \PY{o}{*} \PY{n+nb}{len}\PY{p}{(}\PY{n}{tt}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{n}{f}\PY{p}{(}\PY{n}{tt}\PY{p}{,} \PY{o}{*}\PY{n}{popt\PYZus{}3}\PY{p}{)}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlim}\PY{p}{(}\PY{p}{(}\PY{l+m+mf}{1e\PYZhy{}2}\PY{p}{,} \PY{l+m+mf}{1e3}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylim}\PY{p}{(}\PY{p}{(}\PY{k+kc}{None}\PY{p}{,} \PY{l+m+mf}{1e\PYZhy{}12}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{legend}\PY{p}{(}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{MSD (m\PYZdl{}\PYZca{}2\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{Delta\PYZdl{}t (s)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{31}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0.5, 0, '\$\textbackslash{}\textbackslash{}Delta\$t (s)')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_48_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{32}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{MSD\PYZus{}z\PYZus{}dedrift}\PY{p}{[}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]} \PY{o}{\PYZgt{}} \PY{l+m+mf}{1e2}\PY{p}{]}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{32}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
5.348018604759325e-13
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{33}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} dataset[\PYZdq{}plateau\PYZus{}MSD\PYZdq{}] = popt[0]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{plateau\PYZus{}MSD}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{MSD\PYZus{}z\PYZus{}dedrift}\PY{p}{[}\PY{n}{time}\PY{p}{[}\PY{n}{t}\PY{p}{]} \PY{o}{\PYZgt{}} \PY{l+m+mf}{1e2}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Measured plateau : }\PY{l+s+si}{\PYZob{}:e\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{popt}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Measured plateau : 2.070536e+01
\end{Verbatim}
The MSD plateau is theoritically given by:
\begin{equation}
Plateau = \int _{-\infty} ^{+\infty} \Delta z ^ 2 P_{\Delta z, t \rightarrow +\infty}(\Delta z,B,l_d,l_b) d\Delta z
\end{equation}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{34}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{x\PYZus{}Th\PYZus{}Plateau} \PY{o}{=} \PY{n}{bins\PYZus{}centers\PYZus{}long\PYZus{}t} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{k}{def} \PY{n+nf}{Theoritical\PYZus{}Plateau}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{n}{x} \PY{o}{=} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\PY{n}{P} \PY{o}{=} \PY{n}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)} \PY{o}{/} \PY{n}{trapz}\PY{p}{(}\PY{n}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{,} \PY{n}{x}\PY{p}{)}
\PY{n}{res} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}\PY{p}{(}\PY{n}{x} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{*} \PY{n}{P}\PY{p}{,} \PY{n}{x}\PY{p}{)}
\PY{k}{return} \PY{n}{res}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{35}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{minimize\PYZus{}plateau}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{:}
\PY{n}{B} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{n}{ld} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{lb} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}
\PY{k}{return} \PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{Theoritical\PYZus{}Plateau}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{plateau\PYZus{}MSD}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{)}
\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{Theoritical\PYZus{}Plateau}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{36}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{res\PYZus{}plateau} \PY{o}{=} \PY{n}{minimize}\PY{p}{(}\PY{n}{minimize\PYZus{}plateau}\PY{p}{,} \PY{n}{x0}\PY{o}{=}\PY{p}{[}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{We measure, B = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{, ld = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ nm, lb = }\PY{l+s+si}{\PYZob{}:.2f\PYZcb{}}\PY{l+s+s2}{ nm}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{o}{*}\PY{n}{res\PYZus{}plateau}\PY{o}{.}\PY{n}{x}\PY{p}{)}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
We measure, B = 20.71, ld = 71.84 nm, lb = 504.78 nm
\end{Verbatim}
\hypertarget{pdf-of-heights}{%
\subsection{PDF of heights}\label{pdf-of-heights}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{37}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{logarithmic\PYZus{}hist}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{begin}\PY{p}{,} \PY{n}{stop}\PY{p}{,} \PY{n}{num}\PY{o}{=}\PY{l+m+mi}{50}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{begin} \PY{o}{==} \PY{l+m+mi}{0}\PY{p}{:}
\PY{n}{beg} \PY{o}{=} \PY{n}{stop} \PY{o}{/} \PY{n}{num}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{logspace}\PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{beg}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{stop}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{num} \PY{o}{\PYZhy{}} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{n}{base}
\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{cumsum}\PY{p}{(}\PY{n}{widths}\PY{p}{[}\PY{p}{:}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{concatenate}\PY{p}{(}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{p}{)}\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{k}{else}\PY{p}{:}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{logspace}\PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{begin}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{stop}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{num}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{n}{base}
\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{histogram}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{n}{bins}\PY{p}{,} \PY{n}{density}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{c+c1}{\PYZsh{} normalize by bin width}
\PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{p}{(}\PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{+} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}
\PY{k}{return} \PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{widths}\PY{p}{,} \PY{n}{hist}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{38}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{z\PYZus{}dedrift}\PY{p}{[}\PY{n}{z\PYZus{}dedrift} \PY{o}{\PYZlt{}} \PY{l+m+mf}{1.5}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{150}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZdl{}P\PYZus{}z(z)\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{38}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0, 0.5, '\$P\_z(z)\$')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_57_1.png}
\end{center}
{ \hspace*{\fill} \\}
The idea now is to find where the substrate is, to do this we will use a
first method which consist to adjust the PDF with an offset to make it
fit with the measured mean Diffusion coefficient. With :
\begin{equation}
< D_i > = \int _{-\infty} ^{\infty} dz D_i(z)P(z)
\end{equation}
For z we are going to use the Padé approx :
\begin{equation} D_z (z) \approx D_0 \left( \frac{6z^2 + 2rz}{6z^2 + 9rz + 2r^2} \right) \end{equation}
For x we are going to use the Faxen formula :
\begin{equation} D_x (z) \approx D_0 \left[ 1 - \frac{9}{16} \left(\frac{r}{z}\right) + \frac{1}{8} \left(\frac{r}{z}\right)^3 - \frac{45}{236} \left(\frac{r}{z}\right)^4 - \frac{1}{16} \left(\frac{r}{z}\right)^5 \right] \end{equation}
To do this we will fit the PDF with an offset, adjust it with the mean
value of z. Let's first do it over z
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{39}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{n}{z\PYZus{}off} \PY{o}{=} \PY{n}{z\PYZus{}off} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{lb} \PY{o}{=} \PY{n}{lb} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}
\PY{n}{ld} \PY{o}{=} \PY{n}{ld} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}9}
\PY{n}{z} \PY{o}{=} \PY{n}{z} \PY{o}{\PYZhy{}} \PY{n}{z\PYZus{}off}
\PY{n}{P\PYZus{}b} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{B} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{z} \PY{o}{/} \PY{p}{(}\PY{n}{ld}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{z} \PY{o}{/} \PY{n}{lb}\PY{p}{)}
\PY{n}{P\PYZus{}b}\PY{p}{[}\PY{n}{z} \PY{o}{\PYZlt{}} \PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{0}
\PY{c+c1}{\PYZsh{} Normalization of P\PYZus{}b}
\PY{n}{A} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}\PY{n}{P\PYZus{}b}\PY{p}{,} \PY{n}{z} \PY{o}{*} \PY{l+m+mf}{1e6}\PY{p}{)}
\PY{n}{P\PYZus{}b} \PY{o}{=} \PY{n}{P\PYZus{}b} \PY{o}{/} \PY{n}{A}
\PY{k}{return} \PY{n}{P\PYZus{}b}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{40}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Normalization of the PDF}
\PY{n}{pdf\PYZus{}z} \PY{o}{=} \PY{n}{pdf\PYZus{}z} \PY{o}{/} \PY{n}{trapz}\PY{p}{(}\PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{)}
\PY{n}{p2} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}
\PY{n}{popt}\PY{p}{,} \PY{n}{pcov} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{,} \PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{n}{p2}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
<ipython-input-39-f5e0b340e678>:6: RuntimeWarning: overflow encountered in exp
P\_b = np.exp(-B * np.exp(-z / (ld)) - z / lb)
<ipython-input-39-f5e0b340e678>:12: RuntimeWarning: invalid value encountered in
true\_divide
P\_b = P\_b / A
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{41}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{semilogy}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{o}{*}\PY{n}{popt}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z \PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{(}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m)\PYZcb{}\PYZdl{}}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{P(z)}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{grid}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_61_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{42}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{mean\PYZus{}Dx} \PY{o}{=} \PY{p}{(}\PY{n}{popt\PYZus{}1}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+} \PY{n}{popt\PYZus{}2}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}
\PY{n}{mean\PYZus{}Dz} \PY{o}{=} \PY{n}{popt\PYZus{}3}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{n+nb}{print}\PY{p}{(}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{We measure a mean diffusion coefficient of }\PY{l+s+si}{\PYZob{}:.3f\PYZcb{}}\PY{l+s+s2}{D0 for the perpendicular motion and of }\PY{l+s+si}{\PYZob{}:.3f\PYZcb{}}\PY{l+s+s2}{D0 for the parallel motion}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}
\PY{p}{(}\PY{n}{popt\PYZus{}1}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+} \PY{n}{popt\PYZus{}2}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}\PY{p}{,} \PY{n}{popt\PYZus{}3}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{p}{)}
\PY{p}{)}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}para}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{mean\PYZus{}Dx}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}perp}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{mean\PYZus{}Dz}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
We measure a mean diffusion coefficient of 0.522D0 for the perpendicular motion
and of 0.243D0 for the parallel motion
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{43}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{Do} \PY{o}{=} \PY{l+m+mf}{4e\PYZhy{}21} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{l+m+mf}{0.001} \PY{o}{*} \PY{n}{r}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{z}\PY{p}{)}\PY{p}{:}
\PY{n}{result} \PY{o}{=} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{z} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{2} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{z}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{z} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{9} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{2} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{r}\PY{p}{)}
\PY{k}{return} \PY{n}{result}
\PY{k}{def} \PY{n+nf}{Dx\PYZus{}z}\PY{p}{(}\PY{n}{z}\PY{p}{)}\PY{p}{:}
\PY{n}{result} \PY{o}{=} \PY{p}{(}
\PY{l+m+mi}{1}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{9} \PY{o}{/} \PY{l+m+mi}{16} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)}
\PY{o}{+} \PY{l+m+mi}{1} \PY{o}{/} \PY{l+m+mi}{8} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{3}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{45} \PY{o}{/} \PY{l+m+mi}{256} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{4}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{1} \PY{o}{/} \PY{l+m+mi}{16} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{5}
\PY{p}{)}
\PY{k}{return} \PY{n}{result}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{44}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{minimizer}\PY{p}{(}\PY{n}{z\PYZus{}off}\PY{p}{)}\PY{p}{:}
\PY{n}{Dx\PYZus{}pdf} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}
\PY{n}{Dx\PYZus{}z}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{)}
\PY{o}{*} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{o}{*}\PY{n}{popt}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]}\PY{p}{)}\PY{p}{,}
\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,}
\PY{p}{)}
\PY{n}{Dz\PYZus{}pdf} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}
\PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{)}
\PY{o}{*} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{o}{*}\PY{n}{popt}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]}\PY{p}{)}\PY{p}{,}
\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,}
\PY{p}{)}
\PY{k}{return} \PY{n}{np}\PY{o}{.}\PY{n}{abs}\PY{p}{(}\PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{mean\PYZus{}Dx} \PY{o}{/} \PY{n}{Dx\PYZus{}pdf}\PY{p}{)} \PY{o}{+} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{mean\PYZus{}Dx} \PY{o}{/} \PY{n}{Dx\PYZus{}pdf}\PY{p}{)}\PY{p}{)}
\PY{n}{res} \PY{o}{=} \PY{n}{minimize}\PY{p}{(}\PY{n}{minimizer}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{method}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{nelder\PYZhy{}mead}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{45}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{offset} \PY{o}{=} \PY{n}{res}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{46}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{offset} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}\PY{n}{res}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{final\PYZus{}simplex}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{From the measurement of the mean diffusion coefficient, we measure an offset of }\PY{l+s+si}{\PYZob{}:.3f\PYZcb{}}\PY{l+s+s2}{ um}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}
\PY{n}{offset}
\PY{p}{)}
\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
From the measurement of the mean diffusion coefficient, we measure an offset of
0.005 um
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{47}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{logarithmic\PYZus{}hist}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{begin}\PY{p}{,} \PY{n}{stop}\PY{p}{,} \PY{n}{num}\PY{o}{=}\PY{l+m+mi}{50}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{:}
\PY{l+s+sd}{\PYZdq{}\PYZdq{}\PYZdq{}}
\PY{l+s+sd}{ Function to make logarithmic histograms to have more points}
\PY{l+s+sd}{ near the surface and where the particle spend the most of its time.}
\PY{l+s+sd}{ \PYZdq{}\PYZdq{}\PYZdq{}}
\PY{k}{if} \PY{n}{begin} \PY{o}{==} \PY{l+m+mi}{0}\PY{p}{:}
\PY{n}{beg} \PY{o}{=} \PY{n}{stop} \PY{o}{/} \PY{n}{num}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{logspace}\PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{beg}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{stop}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{num} \PY{o}{\PYZhy{}} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{n}{base}
\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{cumsum}\PY{p}{(}\PY{n}{widths}\PY{p}{[}\PY{p}{:}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{concatenate}\PY{p}{(}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{p}{)}\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{k}{else}\PY{p}{:}
\PY{n}{bins} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{logspace}\PY{p}{(}
\PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{begin}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{stop}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{n}{base}\PY{p}{)}\PY{p}{,} \PY{n}{num}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{n}{base}
\PY{p}{)}
\PY{n}{widths} \PY{o}{=} \PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{hist}\PY{p}{,} \PY{n}{a} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{histogram}\PY{p}{(}\PY{n}{data}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{n}{bins}\PY{p}{,} \PY{n}{density}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{c+c1}{\PYZsh{} normalize by bin width}
\PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{p}{(}\PY{n}{bins}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]} \PY{o}{+} \PY{n}{bins}\PY{p}{[}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}
\PY{k}{return} \PY{n}{bins\PYZus{}center}\PY{p}{,} \PY{n}{widths}\PY{p}{,} \PY{n}{hist}
\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{widths}\PY{p}{,} \PY{n}{pdf\PYZus{}z} \PY{o}{=} \PY{n}{logarithmic\PYZus{}hist}\PY{p}{(}\PY{n}{z\PYZus{}dedrift}\PY{p}{,} \PY{l+m+mf}{0.01}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{,} \PY{n}{num}\PY{o}{=}\PY{l+m+mi}{50}\PY{p}{,} \PY{n}{base}\PY{o}{=}\PY{l+m+mi}{12}\PY{p}{)}
\PY{n}{p2} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}
\PY{n}{popt\PYZus{}pdf}\PY{p}{,} \PY{n}{pcov\PYZus{}pdf} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{,} \PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{n}{p0}\PY{o}{=}\PY{n}{p2}\PY{p}{)}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{pdf\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{pdf\PYZus{}z}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{plt}\PY{o}{.}\PY{n}{semilogy}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{pdf\PYZus{}z}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{o}{*}\PY{n}{popt\PYZus{}pdf}\PY{p}{)}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{black}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z (\PYZdl{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mathrm}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZbs{}}\PY{l+s+s2}{mu m\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{P(z) (\PYZdl{}m\PYZca{}}\PY{l+s+s2}{\PYZob{}}\PY{l+s+s2}{\PYZhy{}1\PYZcb{}\PYZdl{})}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
<ipython-input-39-f5e0b340e678>:6: RuntimeWarning: overflow encountered in exp
P\_b = np.exp(-B * np.exp(-z / (ld)) - z / lb)
<ipython-input-39-f5e0b340e678>:12: RuntimeWarning: invalid value encountered in
true\_divide
P\_b = P\_b / A
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{47}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
Text(0, 0.5, 'P(z) (\$m\^{}\{-1\}\$)')
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_67_2.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{48}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{offset\PYZus{}pdf}\PY{p}{,} \PY{n}{B\PYZus{}pdf}\PY{p}{,} \PY{n}{ld\PYZus{}offset}\PY{p}{,} \PY{n}{lb\PYZus{}offset} \PY{o}{=} \PY{n}{popt\PYZus{}pdf}
\end{Verbatim}
\end{tcolorbox}
We write the diffusion function.
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{49}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{off}\PY{p}{)}\PY{p}{:}
\PY{n}{off} \PY{o}{=} \PY{n}{off} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{z} \PY{o}{=} \PY{n}{z} \PY{o}{\PYZhy{}} \PY{n}{off}
\PY{n}{result} \PY{o}{=} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{z} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{2} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{z}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{z} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{9} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{z} \PY{o}{+} \PY{l+m+mi}{2} \PY{o}{*} \PY{n}{r} \PY{o}{*} \PY{n}{r}\PY{p}{)}
\PY{k}{return} \PY{n}{result}
\PY{k}{def} \PY{n+nf}{Dx\PYZus{}z\PYZus{}off}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{offset}\PY{p}{)}\PY{p}{:}
\PY{n}{offset} \PY{o}{=} \PY{n}{offset} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{z} \PY{o}{=} \PY{n}{z} \PY{o}{+} \PY{n}{offset}
\PY{n}{result} \PY{o}{=} \PY{p}{(}
\PY{l+m+mi}{1}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{9} \PY{o}{/} \PY{l+m+mi}{16} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)}
\PY{o}{+} \PY{l+m+mi}{1} \PY{o}{/} \PY{l+m+mi}{8} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{3}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{45} \PY{o}{/} \PY{l+m+mi}{256} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{4}
\PY{o}{\PYZhy{}} \PY{l+m+mi}{1} \PY{o}{/} \PY{l+m+mi}{16} \PY{o}{*} \PY{p}{(}\PY{n}{r} \PY{o}{/} \PY{p}{(}\PY{n}{z} \PY{o}{+} \PY{n}{r}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{5}
\PY{p}{)}
\PY{k}{return} \PY{n}{result}
\end{Verbatim}
\end{tcolorbox}
\hypertarget{measuring-the-diffusion-coefficient-using-the-frishman-and-roncerays-method}{%
\subsection{Measuring the diffusion coefficient using the Frishman and
Ronceray's
method}\label{measuring-the-diffusion-coefficient-using-the-frishman-and-roncerays-method}}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{50}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{io} \PY{k+kn}{import} \PY{n}{loadmat}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}0}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{l+m+mf}{4e\PYZhy{}21} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{6} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{l+m+mf}{0.001} \PY{o}{*} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{r}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{)}
\PY{n}{D} \PY{o}{=} \PY{n}{loadmat}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{diffusionAnalysis.mat}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{diffusion}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{D}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{D}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]} \PY{o}{+} \PY{n}{D}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{]}\PY{p}{)} \PY{o}{/} \PY{l+m+mi}{2}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{D}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{3}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{51}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{/} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}0}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{loglog}\PY{p}{(}\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{/} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}0}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{o}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{zz} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{1e\PYZhy{}8}\PY{p}{,} \PY{l+m+mf}{1e\PYZhy{}5}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{zz}\PY{p}{,} \PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{zz}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{zz}\PY{p}{,} \PY{n}{Dx\PYZus{}z\PYZus{}off}\PY{p}{(}\PY{n}{zz}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{k}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{51}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
[<matplotlib.lines.Line2D at 0x27a85cc7850>]
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{data_analyse_files/data_analyse_73_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{52}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{c\PYZus{}P\PYZus{}D}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{,} \PY{n}{offset}\PY{o}{=}\PY{k+kc}{None}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{offset} \PY{o}{==} \PY{k+kc}{None}\PY{p}{:}
\PY{n}{offset} \PY{o}{=} \PY{l+m+mi}{0}
\PY{n}{z} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{1e\PYZhy{}9}\PY{p}{,} \PY{l+m+mf}{15e\PYZhy{}6}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}
\PY{n}{P\PYZus{}D} \PY{o}{=} \PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{offset}\PY{p}{)} \PY{o}{*} \PY{n}{Do} \PY{o}{*} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{offset}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{k}{return} \PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{z}\PY{p}{,} \PY{n}{offset}\PY{p}{)} \PY{o}{*} \PY{n}{Do}\PY{p}{,} \PY{n}{P\PYZus{}D} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{trapz}\PY{p}{(}\PY{n}{P\PYZus{}D}\PY{p}{,} \PY{n}{z}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{\PYZus{}P\PYZus{}Dz\PYZus{}short\PYZus{}time}\PY{p}{(}\PY{n}{Dz}\PY{p}{,} \PY{n}{Dt}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{,} \PY{n}{offset}\PY{o}{=}\PY{k+kc}{None}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{offset} \PY{o}{==} \PY{k+kc}{None}\PY{p}{:}
\PY{n}{offset} \PY{o}{=} \PY{l+m+mi}{0}
\PY{n}{D\PYZus{}z}\PY{p}{,} \PY{n}{P\PYZus{}D} \PY{o}{=} \PY{n}{c\PYZus{}P\PYZus{}D}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{,} \PY{n}{offset}\PY{p}{)}
\PY{n}{P} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{trapz}\PY{p}{(}
\PY{n}{P\PYZus{}D} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{l+m+mi}{4} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{D\PYZus{}z} \PY{o}{*} \PY{n}{Dt}\PY{p}{)} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{n}{Dz} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{4} \PY{o}{*} \PY{n}{D\PYZus{}z} \PY{o}{*} \PY{n}{Dt}\PY{p}{)}\PY{p}{)}\PY{p}{,} \PY{n}{D\PYZus{}z}
\PY{p}{)}
\PY{k}{return} \PY{n}{P}
\PY{k}{def} \PY{n+nf}{P\PYZus{}Dz\PYZus{}short\PYZus{}time}\PY{p}{(}\PY{n}{Dz}\PY{p}{,} \PY{n}{Dt}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{,} \PY{n}{offset}\PY{o}{=}\PY{k+kc}{None}\PY{p}{)}\PY{p}{:}
\PY{k}{if} \PY{n}{offset} \PY{o}{==} \PY{k+kc}{None}\PY{p}{:}
\PY{n}{offset} \PY{o}{=} \PY{l+m+mi}{0}
\PY{n}{P} \PY{o}{=} \PY{p}{[}\PY{n}{\PYZus{}P\PYZus{}Dz\PYZus{}short\PYZus{}time}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{n}{Dt}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{,} \PY{n}{offset}\PY{o}{=}\PY{n}{offset}\PY{p}{)} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{Dz}\PY{p}{]}
\PY{n}{P} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{n}{P}\PY{p}{)}
\PY{n}{P} \PY{o}{=} \PY{n}{P} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{trapz}\PY{p}{(}\PY{n}{P}\PY{p}{,} \PY{n}{Dz}\PY{p}{)}
\PY{k}{return} \PY{n}{P}
\end{Verbatim}
\end{tcolorbox}
\hypertarget{fit-everything-in-the-same-time}{%
\section{Fit everything in the same time
!}\label{fit-everything-in-the-same-time}}
Finaly we can fit everything in the same time to recap we have :
\begin{itemize}
\tightlist
\item
MSD x and MSD y =\textgreater{} \(< D >\)
\item
MSD z =\textgreater{} \(< D >\)
\item
mean \(< D >\) with the pdf
\item
Long time pdf \(\Delta z\) =\textgreater{} \(l_d,l_b,B\)
\item
Pdf z =\textgreater{} \(offset,l_d,l_b, B\)
\item
D parallel, perp =\textgreater{} offset
\end{itemize}
The minimizer \(\chi ^2\) we are going to optimize can be written as :
\begin{equation} \chi^2 = \sum _{n = 1} ^{N} \chi_n^2 \end{equation}\begin{equation} \chi_n^2 = \sum^A(n) _i = 1 \frac{1}{\sigma_{ni}}(y_{ni} - y_n(x_{ni},\boldsymbol{a}))^2 \end{equation}
with \(\sigma_{ni}\) the uncertainty (can be set to 1), A the number of
point in the dataset for each function, \(y_n\), nth equation,
\(\boldsymbol{a}\) the fit parameters
We have nonlinear functions so we can use the Marquardt to optimize or
Nelder-Mead methods to optimize the minimizer.
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{53}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{def} \PY{n+nf}{minimizer\PYZus{}diffusion\PYZus{}coeff}\PY{p}{(}\PY{n}{mean\PYZus{}D\PYZus{}para}\PY{p}{,} \PY{n}{mean\PYZus{}D\PYZus{}perp}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{c+c1}{\PYZsh{} minimization of the mean diffusion coefficient measurement with the PDF and MSD}
\PY{n}{a} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}
\PY{n}{Dx\PYZus{}z\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{)}
\PY{o}{*} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{,}
\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,}
\PY{p}{)}
\PY{n}{b} \PY{o}{=} \PY{n}{trapz}\PY{p}{(}
\PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{)}
\PY{o}{*} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}\PY{p}{,} \PY{n}{z\PYZus{}off}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{,}
\PY{n}{bins\PYZus{}center\PYZus{}pdf\PYZus{}z}\PY{p}{,}
\PY{p}{)}
\PY{n}{at} \PY{o}{=} \PY{n}{mean\PYZus{}Dx}
\PY{n}{bt} \PY{o}{=} \PY{n}{mean\PYZus{}Dz}
\PY{k}{return} \PY{p}{(}\PY{n}{a} \PY{o}{\PYZhy{}} \PY{n}{at}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2} \PY{o}{/} \PY{n}{at} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2} \PY{o}{+} \PY{p}{(}\PY{n}{b} \PY{o}{\PYZhy{}} \PY{n}{bt}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2} \PY{o}{/} \PY{n}{bt} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{z\PYZus{}dedrift}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{x}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{y}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{y}
\PY{k}{def} \PY{n+nf}{minimizer\PYZus{}Dz\PYZus{}small\PYZus{}t}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{:}
\PY{n}{xi} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{for} \PY{n}{n}\PY{p}{,} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{,} \PY{l+m+mi}{3}\PY{p}{]}\PY{p}{)}\PY{p}{:}
\PY{n}{Dezs} \PY{o}{=} \PY{p}{(}\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{n}{i}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{[}\PY{n}{i}\PY{p}{:}\PY{p}{]}\PY{p}{)} \PY{o}{*} \PY{l+m+mf}{1e\PYZhy{}6}
\PY{n}{Dezs} \PY{o}{=} \PY{n}{Dezs} \PY{c+c1}{\PYZsh{} \PYZhy{} np.mean(Dezs)}
\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center} \PY{o}{=} \PY{n}{pdf}\PY{p}{(}\PY{n}{Dezs}\PY{p}{[}\PY{o}{\PYZti{}}\PY{n}{np}\PY{o}{.}\PY{n}{isnan}\PY{p}{(}\PY{n}{Dezs}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mi}{30}\PY{p}{)}
\PY{n}{hist} \PY{o}{=} \PY{n}{hist} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{trapz}\PY{p}{(}\PY{n}{hist}\PY{p}{,} \PY{n}{bins\PYZus{}center}\PY{p}{)}
\PY{n}{Dz\PYZus{}th} \PY{o}{=} \PY{n}{bins\PYZus{}center}
\PY{n}{PPP} \PY{o}{=} \PY{n}{P\PYZus{}Dz\PYZus{}short\PYZus{}time}\PY{p}{(}\PY{n}{Dz\PYZus{}th}\PY{p}{,} \PY{n}{time}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{c+c1}{\PYZsh{} xi = xi + np.nanmean((((np.abs(hist) \PYZhy{} (PPP) ) ) ** 2) / ((np.abs(hist)**2)))}
\PY{n}{xi} \PY{o}{=} \PY{n}{xi} \PY{o}{+} \PY{n}{np}\PY{o}{.}\PY{n}{nanmean}\PY{p}{(}
\PY{p}{(}\PY{p}{(}\PY{n}{hist}\PY{p}{[}\PY{n}{hist} \PY{o}{\PYZgt{}} \PY{l+m+mi}{0}\PY{p}{]} \PY{o}{\PYZhy{}} \PY{n}{PPP}\PY{p}{[}\PY{n}{hist} \PY{o}{\PYZgt{}} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{n}{hist}\PY{p}{[}\PY{n}{hist} \PY{o}{\PYZgt{}} \PY{l+m+mi}{0}\PY{p}{]} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}
\PY{p}{)}
\PY{k}{return} \PY{n}{xi}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{54}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}para}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{mean\PYZus{}Dx}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}perp}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{=} \PY{n}{mean\PYZus{}Dz}
\PY{k}{def} \PY{n+nf}{minimizer}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{o}{*}\PY{n}{args}\PY{p}{)}\PY{p}{:}
\PY{n}{data} \PY{o}{=} \PY{n}{dataset}
\PY{n}{ld} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
\PY{n}{lb} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}
\PY{n}{B} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}
\PY{n}{offset\PYZus{}dif} \PY{o}{=} \PY{n}{x}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}
\PY{n}{chi\PYZus{}mean\PYZus{}D\PYZus{}pdf} \PY{o}{=} \PY{n}{minimizer\PYZus{}diffusion\PYZus{}coeff}\PY{p}{(}
\PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}para}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{dataset}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{D\PYZus{}perp}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}
\PY{p}{)}
\PY{n}{chi\PYZus{}MSD\PYZus{}plateau} \PY{o}{=} \PY{n}{minimize\PYZus{}plateau}\PY{p}{(}\PY{p}{[}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{]}\PY{p}{)}
\PY{n}{E\PYZus{}longtime\PYZus{}pdf} \PY{o}{=} \PY{p}{(}\PY{n}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{p}{(}
\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\PY{p}{)}
\PY{n}{chi\PYZus{}longtime\PYZus{}pdf} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}
\PY{p}{(}\PY{n}{E\PYZus{}longtime\PYZus{}pdf}\PY{p}{[}\PY{n}{E\PYZus{}longtime\PYZus{}pdf} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{n}{np}\PY{o}{.}\PY{n}{inf}\PY{p}{]} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{p}{(}\PY{n}{Pdeltaz\PYZus{}long}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}longtime}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{p}{)}
\PY{n}{E\PYZus{}chi\PYZus{}pdf\PYZus{}z} \PY{o}{=} \PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{pdf\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}
\PY{n}{chi\PYZus{}pdf\PYZus{}z} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{nanmean}\PY{p}{(}
\PY{p}{(}\PY{n}{E\PYZus{}chi\PYZus{}pdf\PYZus{}z}\PY{p}{[}\PY{n}{E\PYZus{}chi\PYZus{}pdf\PYZus{}z} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{n}{np}\PY{o}{.}\PY{n}{inf}\PY{p}{]} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{P\PYZus{}b\PYZus{}off}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{x\PYZus{}pdf\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{p}{)}
\PY{n}{E\PYZus{}D\PYZus{}z} \PY{o}{=} \PY{p}{(}\PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{offset\PYZus{}dif}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}z}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{/} \PY{n}{Do}\PY{p}{)}
\PY{n}{chi\PYZus{}D\PYZus{}z} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}
\PY{p}{(}\PY{n}{E\PYZus{}D\PYZus{}z}\PY{p}{[}\PY{n}{E\PYZus{}D\PYZus{}z} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{n}{np}\PY{o}{.}\PY{n}{inf}\PY{p}{]} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{Dz\PYZus{}z}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{offset\PYZus{}dif}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{p}{)}
\PY{n}{E\PYZus{}D\PYZus{}x} \PY{o}{=} \PY{p}{(}\PY{n}{Dx\PYZus{}z\PYZus{}off}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{offset\PYZus{}dif}\PY{p}{)}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D\PYZus{}x}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]} \PY{o}{/} \PY{n}{Do}\PY{p}{)}
\PY{n}{chi\PYZus{}D\PYZus{}x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{mean}\PY{p}{(}
\PY{p}{(}\PY{n}{E\PYZus{}D\PYZus{}x}\PY{p}{[}\PY{n}{E\PYZus{}D\PYZus{}x} \PY{o}{\PYZgt{}} \PY{o}{\PYZhy{}}\PY{n}{np}\PY{o}{.}\PY{n}{inf}\PY{p}{]} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{p}{(}\PY{n}{Dx\PYZus{}z\PYZus{}off}\PY{p}{(}\PY{n}{data}\PY{p}{[}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{z\PYZus{}D}\PY{l+s+s2}{\PYZdq{}}\PY{p}{]}\PY{p}{,} \PY{n}{offset\PYZus{}dif}\PY{p}{)}\PY{p}{)} \PY{o}{*}\PY{o}{*} \PY{l+m+mi}{2}\PY{p}{)}
\PY{p}{)}
\PY{n}{chi\PYZus{}Dz\PYZus{}small\PYZus{}t} \PY{o}{=} \PY{n}{minimizer\PYZus{}Dz\PYZus{}small\PYZus{}t}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{ld}\PY{p}{,} \PY{n}{lb}\PY{p}{)}
\PY{n}{summ} \PY{o}{=} \PY{p}{(}
\PY{n}{chi\PYZus{}mean\PYZus{}D\PYZus{}pdf}
\PY{o}{+} \PY{n}{chi\PYZus{}MSD\PYZus{}plateau}
\PY{o}{+} \PY{n}{chi\PYZus{}longtime\PYZus{}pdf}
\PY{o}{+} \PY{n}{chi\PYZus{}pdf\PYZus{}z}
\PY{o}{+} \PY{n}{chi\PYZus{}D\PYZus{}z}
\PY{o}{+} \PY{n}{chi\PYZus{}D\PYZus{}x}
\PY{o}{+} \PY{n}{chi\PYZus{}Dz\PYZus{}small\PYZus{}t}
\PY{p}{)}
\PY{k}{return} \PY{n}{summ}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{55}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{B} \PY{o}{=} \PY{l+m+mi}{5}
\PY{n}{ld} \PY{o}{=} \PY{n}{ld\PYZus{}offset}
\PY{n}{x0} \PY{o}{=} \PY{p}{[}\PY{n}{ld}\PY{p}{,} \PY{l+m+mi}{550}\PY{p}{,} \PY{n}{B}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{n}{offset\PYZus{}pdf}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{56}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{optimize} \PY{k+kn}{import} \PY{n}{leastsq}
\PY{n}{options} \PY{o}{=} \PY{p}{\PYZob{}}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{maxc1or}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mi}{30}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ftol}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{2.2e\PYZhy{}10}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{gtol}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{1e\PYZhy{}5}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{eps}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mf}{1e\PYZhy{}08}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{maxfun}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mi}{15000}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{maxiter}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mi}{15000}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{maxls}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+m+mi}{20}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{finite\PYZus{}diff\PYZus{}rel\PYZus{}step}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{k+kc}{None}\PY{p}{,}
\PY{p}{\PYZcb{}}
\PY{n}{res} \PY{o}{=} \PY{n}{minimize}\PY{p}{(}
\PY{n}{minimizer}\PY{p}{,}
\PY{n}{x0}\PY{p}{,}
\PY{n}{method}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{BFGS}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}
\PY{n}{tol}\PY{o}{=}\PY{l+m+mf}{1e\PYZhy{}1}\PY{p}{,}
\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{57}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{res}\PY{o}{.}\PY{n}{x}
\PY{n}{results} \PY{o}{=} \PY{p}{\PYZob{}}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ld}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{n}{res}\PY{o}{.}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{lb}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{n}{res}\PY{o}{.}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{B}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{n}{res}\PY{o}{.}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{,}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{offset\PYZus{}diffusion}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{n}{res}\PY{o}{.}\PY{n}{x}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{,}
\PY{p}{\PYZcb{}}
\PY{n}{results}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{57}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\{'ld': 25.53322987706852,
'lb': 549.9956782843908,
'B': 4.856896668800334,
'offset\_diffusion': 0.0019089236000464675\}
\end{Verbatim}
\end{tcolorbox}
This final result has been used to plot theories along the manuscript.
% Add a bibliography block to the postdoc
\end{document}
|
{"hexsha": "209eaeef869d361835bb4524311bbfa252241ce3", "size": 133309, "ext": "tex", "lang": "TeX", "max_stars_repo_path": "03_tail/data_analyse.tex", "max_stars_repo_name": "eXpensia/Confined-Brownian-Motion", "max_stars_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "03_tail/data_analyse.tex", "max_issues_repo_name": "eXpensia/Confined-Brownian-Motion", "max_issues_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "03_tail/data_analyse.tex", "max_forks_repo_name": "eXpensia/Confined-Brownian-Motion", "max_forks_repo_head_hexsha": "bd0eb6dea929727ea081dae060a7d1aa32efafd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.9417628541, "max_line_length": 455, "alphanum_fraction": 0.5496028025, "num_tokens": 63171}
|
'''reorganizes full 20 year 100% timeseries into 25/50/100% 5/10/20 year ones. So less extensive sureys can be done.
2020-01-01T19:00:00.000 = 2458850.29166667 # start date
2025-01-01T19:00:00.000 = 2460677.29166667 # 5 years
2030-01-01T19:00:00.000 = 2462503.29166667 # 10 years
2040-01-01T19:00:00.000 = 2466155.29166667 # 20 years
'''
import numpy as np
#Filenames list is subject to change. This one is complete for the 52 star declination cut target list. You should probably hand edit it for a given series.
filenames=["HIP104214_rvPlanets.txt","HIP25878_rvPlanets.txt","HIP67927_rvPlanets.txt","HIP104217_rvPlanets.txt","HIP27072_rvPlanets.txt","HIP68184_rvPlanets.txt","HIP10644_rvPlanets.txt","HIP29295_rvPlanets.txt","HIP72848_rvPlanets.txt","HIP109176_rvPlanets.txt","HIP3093_rvPlanets.txt","HIP73184_rvPlanets.txt","HIP114622_rvPlanets.txt","HIP32984_rvPlanets.txt","HIP7513_rvPlanets.txt","HIP12114_rvPlanets.txt","HIP37279_rvPlanets.txt","HIP77257_rvPlanets.txt","HIP12777_rvPlanets.txt","HIP3765_rvPlanets.txt","HIP78072_rvPlanets.txt","HIP13402_rvPlanets.txt","HIP3821_rvPlanets.txt","HIP7981_rvPlanets.txt","HIP14632_rvPlanets.txt","HIP47080_rvPlanets.txt","HIP8102_rvPlanets.txt","HIP1475B_rvPlanets.txt","HIP49908_rvPlanets.txt","HIP81300_rvPlanets.txt","HIP1475_rvPlanets.txt","HIP51459_rvPlanets.txt","HIP8362_rvPlanets.txt","HIP15457_rvPlanets.txt","HIP54035_rvPlanets.txt","HIP84478_rvPlanets.txt","HIP16537_rvPlanets.txt","HIP56997_rvPlanets.txt","HIP88972_rvPlanets.txt","HIP17378_rvPlanets.txt","HIP57757_rvPlanets.txt","HIP96100_rvPlanets.txt","HIP19849_rvPlanets.txt","HIP57939_rvPlanets.txt","HIP98036_rvPlanets.txt","HIP22449_rvPlanets.txt","HIP61317_rvPlanets.txt","HIP99825_rvPlanets.txt","HIP23311_rvPlanets.txt","HIP64394_rvPlanets.txt","HIP24813_rvPlanets.txt","HIP64924_rvPlanets.txt"]
for filename in filenames:
try:
star = np.genfromtxt(filename, delimiter=',', names=True, dtype=None)
except:
print("Does not exist:",filename)
else:
print(filename)
# open 5, 10 year 100%
star5year100 = open(filename+"05100", 'w')
star5year100.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
star10year100 = open(filename+"10100", 'w')
star10year100.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
for line in star:
if (line["obs_start"] < 2460677.29166667):
star5year100.write(str(line)[1:-1]+"\n")
if (line["obs_start"] < 2462503.29166667):
star10year100.write(str(line)[1:-1]+"\n")
star5year100.close()
star10year100.close()
star5year050 = open(filename+"05050", 'w')
star5year050.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
star10year050 = open(filename+"10050", 'w')
star10year050.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
star20year050 = open(filename+"20050", 'w')
star20year050.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
np.random.shuffle(star)
starpos = np.arange(int(0.5*len(star)))
for line in starpos: # iterate over the first half of a random shuffle of our observations
star20year050.write(str(star[line])[1:-1]+"\n")
if (star[line]["obs_start"] < 2460677.29166667):
star5year050.write(str(star[line])[1:-1]+"\n")
if (star[line]["obs_start"] < 2462503.29166667):
star10year050.write(str(star[line])[1:-1]+"\n")
star5year050.close()
star10year050.close()
star20year050.close()
star5year025 = open(filename+"05025", 'w')
star5year025.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
star10year025 = open(filename+"10025", 'w')
star10year025.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
star20year025 = open(filename+"20025", 'w')
star20year025.write("obs_start,obs_end,duration,altitude,azimuth,exposures,photonprec,instprec,rvprec,rvmeas,mnvel\n")
np.random.shuffle(star) # new shuffle so 25% is different from 50%
starpos = np.arange(int(0.25*len(star)))
for line in starpos:
star20year025.write(str(star[line])[1:-1]+"\n")
if (star[line]["obs_start"] < 2460677.29166667):
star5year025.write(str(star[line])[1:-1]+"\n")
if (star[line]["obs_start"] < 2462503.29166667):
star10year025.write(str(star[line])[1:-1]+"\n")
star5year025.close()
star10year025.close()
star20year025.close()
|
{"hexsha": "5a9ee226009d063aba40a2ffcf19fa0b8499d9d8", "size": 4563, "ext": "py", "lang": "Python", "max_stars_repo_path": "truncate.py", "max_stars_repo_name": "pdn4kd/isochoric-expander", "max_stars_repo_head_hexsha": "56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "truncate.py", "max_issues_repo_name": "pdn4kd/isochoric-expander", "max_issues_repo_head_hexsha": "56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "truncate.py", "max_forks_repo_name": "pdn4kd/isochoric-expander", "max_forks_repo_head_hexsha": "56bfdc3c7efb3a242ff4ae4c556d70bb7f171e5f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 69.1363636364, "max_line_length": 1307, "alphanum_fraction": 0.7646285339, "include": true, "reason": "import numpy", "num_tokens": 1614}
|
from flask import Flask, request, jsonify
import json
import pickle
import pandas as pd
import numpy as np
import drmodel
app = Flask(__name__)
# Load the model
model = pickle.load(open('model.pkl','rb'))
labels ={
0: "versicolor",
1: "setosa",
2: "virginica"
}
@app.route('/api',methods=['POST'])
def predict():
data = request.get_json(force=True)
predict = model.predict(data['feature'])
return jsonify(predict[0].tolist())
@app.route('/drapi',methods=['POST'])
def drpredict():
data = request.get_json(force=True)
prediction = drmodel.predict(data)
return prediction.to_json()
if __name__ == '__main__':
app.run(debug=False,host='0.0.0.0', port='8000')
|
{"hexsha": "cab58ea6954cc4d3d115ffbddea76b13100853a9", "size": 683, "ext": "py", "lang": "Python", "max_stars_repo_path": "server.py", "max_stars_repo_name": "datarobot-community/mlops-pipeline", "max_stars_repo_head_hexsha": "dbb717f9b805dda6933912daa80d427db350e1a5", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server.py", "max_issues_repo_name": "datarobot-community/mlops-pipeline", "max_issues_repo_head_hexsha": "dbb717f9b805dda6933912daa80d427db350e1a5", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server.py", "max_forks_repo_name": "datarobot-community/mlops-pipeline", "max_forks_repo_head_hexsha": "dbb717f9b805dda6933912daa80d427db350e1a5", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-04T18:28:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-04T18:28:17.000Z", "avg_line_length": 21.34375, "max_line_length": 52, "alphanum_fraction": 0.6925329429, "include": true, "reason": "import numpy", "num_tokens": 183}
|
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Data.FingerTree.View
{r m}
(ℳ : Monoid r m)
where
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Data.List as List using (List; _∷_; [])
open import Data.FingerTree.Structures ℳ
open import Data.FingerTree.Reasoning ℳ
open import Data.FingerTree.Measures ℳ
open import Data.FingerTree.Cons ℳ
open σ ⦃ ... ⦄
{-# DISPLAY σ.μ _ = μ #-}
{-# DISPLAY μ-tree _ x = μ x #-}
{-# DISPLAY μ-deep _ x = μ x #-}
open Monoid ℳ renaming (Carrier to 𝓡)
infixr 5 _◃_
data Viewₗ {a b} (A : Set a) (Σ : Set b) : Set (a ⊔ b) where
nilₗ : Viewₗ A Σ
_◃_ : A → Σ → Viewₗ A Σ
instance
σ-Viewₗ : ∀ {a b} {A : Set a} {Σ : Set b} ⦃ _ : σ A ⦄ ⦃ _ : σ Σ ⦄ → σ (Viewₗ A Σ)
μ ⦃ σ-Viewₗ ⦄ nilₗ = ε
μ ⦃ σ-Viewₗ ⦄ (x ◃ xs) = μ x ∙ μ xs
viewₗ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → μ⟨ Viewₗ Σ (Tree Σ) ⟩≈ (μ xs)
viewₗ empty = nilₗ ⇑
viewₗ (single x) = (x ◃ empty) ⇑[ ℳ ↯ ]
viewₗ (deep (𝓂 ↤ (D₂ a b & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₁ b & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewₗ (deep (𝓂 ↤ (D₃ a b c & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₂ b c & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewₗ (deep (𝓂 ↤ (D₄ a b c d & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₃ b c d & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewₗ (deep (𝓂 ↤ (D₁ a & m & rs) ⇑[ 𝓂≈ ])) with viewₗ m
... | (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ◃ ys ⇑[ p ] = a ◃ deep (μ m ∙ μ rs ↤ D₂ y₁ y₂ & ys & rs ⇑[ ℳ ↯ ] ≈[ ≪∙ (≪∙ yp ⍮ p) ]′) ⇑[ 𝓂≈ ]
... | (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ◃ ys ⇑[ p ] = a ◃ deep (μ m ∙ μ rs ↤ D₃ y₁ y₂ y₃ & ys & rs ⇑[ ℳ ↯ ] ≈[ ≪∙ (≪∙ yp ⍮ p) ]′) ⇑[ 𝓂≈ ]
... | nilₗ ⇑[ p ] = (digitToTree rs [ _ ∙> r ⟿ r ] >>= (λ rs′ → (a ◃ rs′) ⇑)) ≈[ ∙≫ sym (identityˡ _) ⍮ (∙≫ ≪∙ p) ⍮ 𝓂≈ ]
infixl 5 _▹_
data Viewᵣ {a b} (A : Set a) (Σ : Set b) : Set (a ⊔ b) where
nilᵣ : Viewᵣ A Σ
_▹_ : Σ → A → Viewᵣ A Σ
instance
σ-Viewᵣ : ∀ {a b} {A : Set a} {Σ : Set b} ⦃ _ : σ A ⦄ ⦃ _ : σ Σ ⦄ → σ (Viewᵣ A Σ)
μ ⦃ σ-Viewᵣ ⦄ nilᵣ = ε
μ ⦃ σ-Viewᵣ ⦄ (xs ▹ x) = μ xs ∙ μ x
viewᵣ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → μ⟨ Viewᵣ Σ (Tree Σ) ⟩≈ (μ xs)
viewᵣ empty = nilᵣ ⇑
viewᵣ (single x) = empty ▹ x ⇑[ ℳ ↯ ]
viewᵣ (deep (𝓂 ↤ (ls & m & D₂ a b ) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₁ a ⇓⟫ ▹ b) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewᵣ (deep (𝓂 ↤ (ls & m & D₃ a b c ) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₂ a b ⇓⟫ ▹ c) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewᵣ (deep (𝓂 ↤ (ls & m & D₄ a b c d) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₃ a b c ⇓⟫ ▹ d) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
viewᵣ (deep (𝓂 ↤ (ls & m & D₁ a) ⇑[ 𝓂≈ ])) with viewᵣ m
... | ys ▹ (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ⇑[ p ] = deep (μ ls ∙ μ m ↤ ls & ys & D₂ y₁ y₂ ⇑[ ℳ ↯ ] ≈[ ∙≫ (∙≫ yp ⍮ p) ]′) ▹ a ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
... | ys ▹ (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ⇑[ p ] = deep (μ ls ∙ μ m ↤ ls & ys & D₃ y₁ y₂ y₃ ⇑[ ℳ ↯ ] ≈[ ∙≫ (∙≫ yp ⍮ p) ]′) ▹ a ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′
... | nilᵣ ⇑[ p ] = (digitToTree ls [ l <∙ _ ⟿ l ] >>= (λ ls′ → (ls′ ▹ a) ⇑)) ≈[ ℳ ↯ ↣ μ ls ∙ (ε ∙ μ a) ] ≈[ ∙≫ ≪∙ p ⍮ 𝓂≈ ]′
deepₗ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : List Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : Digit Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ (μ m ∙ μ r))
deepₗ [] m r with viewₗ m
deepₗ [] m r | nilₗ ⇑[ n≈ ] = digitToTree r ≈[ ℳ ↯ ↣ ε ∙ (ε ∙ μ r) ] ≈[ ∙≫ ≪∙ n≈ ]′
deepₗ [] m r | ((μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ◃ ys) ⇑[ ys≈ ] = deep (μ m ∙ μ r ↤ D₂ y₁ y₂ & ys & r ⇑[ ≪∙ yp ⍮ sym (assoc _ _ _) ⍮ ≪∙ ys≈ ]) ⇑[ ℳ ↯ ]
deepₗ [] m r | ((μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ◃ ys) ⇑[ ys≈ ] = deep (μ m ∙ μ r ↤ D₃ y₁ y₂ y₃ & ys & r ⇑[ ≪∙ yp ⍮ sym (assoc _ _ _) ⍮ ≪∙ ys≈ ]) ⇑[ ℳ ↯ ]
deepₗ (l ∷ ls) m r = go l ls m r
where
go : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : Σ) → (ls : List Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : Digit Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ μ ls ∙ (μ m ∙ μ r))
go l [] m r = deep ⟪ D₁ l & m & r ⇓⟫ ⇑[ ℳ ↯ ]
go l₁ (l₂ ∷ ls) m r = (go l₂ ls m r [ _ ∙> ls′ ⟿ ls′ ] >>= (l₁ ◂_)) ≈[ ℳ ↯ ]
deepᵣ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : Digit Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : List Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ (μ m ∙ μ r))
deepᵣ l m [] with viewᵣ m
deepᵣ l m [] | nilᵣ ⇑[ p ] = digitToTree l ≈[ sym (identityʳ _) ⍮ ∙≫ (p ⍮ sym (identityʳ _)) ]
deepᵣ l m [] | (ys ▹ (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ μ⟨y⟩≈ ])) ⇑[ p ] = deep (μ l ∙ μ m ↤ l & ys & D₂ y₁ y₂ ⇑[ ∙≫ (∙≫ μ⟨y⟩≈ ⍮ p) ]) ⇑[ ℳ ↯ ]
deepᵣ l m [] | (ys ▹ (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ μ⟨y⟩≈ ])) ⇑[ p ] = deep (μ l ∙ μ m ↤ l & ys & D₃ y₁ y₂ y₃ ⇑[ ∙≫ (∙≫ μ⟨y⟩≈ ⍮ p) ]) ⇑[ ℳ ↯ ]
deepᵣ l m (r ∷ rs) = go (deep ⟪ l & m & D₁ r ⇓⟫ ⇑) rs ≈[ ℳ ↯ ]
where
go : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → ∀ {xs} → μ⟨ Tree Σ ⟩≈ xs → (rs : List Σ) → μ⟨ Tree Σ ⟩≈ (xs ∙ μ rs)
go xs [] = xs ≈[ sym (identityʳ _) ]
go xs (r ∷ rs) = go (xs [ sz <∙ _ ⟿ sz ] >>= (_▸ r)) rs ≈[ ℳ ↯ ]
|
{"hexsha": "268576458d0b5e0e55137bd7bb8322ac23b1470c", "size": 4581, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/FingerTree/View.agda", "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_issues_repo_path": "src/Data/FingerTree/View.agda", "max_issues_repo_name": "oisdk/agda-indexed-fingertree", "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/FingerTree/View.agda", "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 50.9, "max_line_length": 150, "alphanum_fraction": 0.4154114822, "num_tokens": 2838}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.