我最近开始研究朱莉娅的并行处理,我遇到了一个我不太懂的问题。
用julia -p 4
执行Julia之后我想在所有进程中加载Distributions模块,我想定义一个依赖于Distributions的Type。
以下内容显然可以正常使用:
@everywhere using Distributions
type TypeDistrib{T <: Float64}
d::Distributions.Normal{T}
end
如果我编写与模块完全相同的代码,那么它就不会:
module test
@everywhere using Distributions
type TypeDistrib{T <: Float64}
d::Distributions.Normal{T}
end
export TypeDistrib
end
以上显示以下错误消息:
错误:LoadError:UndefVarError:未定义的分布 在include_from_node1(:: String)at ./loading.jl:488 在include_from_node1(:: String)/Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:? 加载/***/test.jl时,从第4行开始的表达式
请你澄清一下我在这里做得不好吗?
注意:我用***替换了错误消息中的完整路径,因为它很混乱。
答案 0 :(得分:3)
public class SignupActivity extends AppCompatActivity implements View.OnTouchListener {
public static final String DB_NAME = "myapp";
private Database mDatabase = null;
@Bind(R.id.input_name) EditText _nameText;
@Bind(R.id.input_firstname) EditText _firstnameText;
@Bind(R.id.input_lastname) EditText _lastnameText;
@Bind(R.id.input_confirmpassword) EditText _confirmpasswordText;
@Bind(R.id.input_email) EditText _emailText;
@Bind(R.id.input_password) EditText _passwordText;
@Bind(R.id.btn_signup) Button _signupButton;
@Bind(R.id.link_login) TextView _loginLink;
@Bind(R.id.ScrollViewSignup) ScrollView _scrollLayout;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
ButterKnife.bind(this);
_signupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MyUtilities.hideSoftKey(SignupActivity.this,v);
signup();
}
});
_loginLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Finish the registration screen and return to the Login activity
finish();
}
});
_scrollLayout.setOnTouchListener(this);
// Create a manager
Manager manager = null;
try {
manager = new Manager(new AndroidContext(getApplicationContext()), Manager.DEFAULT_OPTIONS);
} catch (IOException e) {
e.printStackTrace();
}
// Create or open the database named app
Database database = null;
try {
database = manager.getDatabase(DB_NAME);
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
// The properties that will be saved on the document
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("name", _nameText);
properties.put("password", _passwordText);
properties.put("firstname", _firstnameText);
properties.put("surname", _lastnameText);
properties.put("email", _emailText);
// Create a new document
Document document = database.createDocument();
// Save the document to the database
try {
document.putProperties(properties);
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
// Log the document ID (generated by the database)
// and properties
Log.d(DB_NAME, String.format("Document ID :: %s", document.getId()));
Log.d(DB_NAME, String.format("Learning %s with %s %s %s %s", (String) document.getProperty("name"), (String) document.getProperty("password"),(String) document.getProperty("firstname"),
(String) document.getProperty("surname"), (String) document.getProperty("email") ));
// Create replicators to push & pull changes to & from Sync Gateway.
URL url = null;
try {
url = new URL("http://serverurl:8080/REST-Model-context-root/resources/register");
} catch (MalformedURLException e) {
e.printStackTrace();
}
Replication push = database.createPushReplication(url);
push.setContinuous(true);
// Start replicators
push.start();
}
public void signup() {
if (!validate()) {
onSignupFailed();
return;
}
_signupButton.setEnabled(false);
final ProgressDialog progressDialog = new ProgressDialog(SignupActivity.this,
R.style.AppTheme_Dark_Dialog);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Creating Account...");
progressDialog.show();
String name = _nameText.getText().toString();
String email = _emailText.getText().toString();
String password = _passwordText.getText().toString();
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
// On complete call either onSignupSuccess or onSignupFailed
// depending on success
onSignupSuccess();
progressDialog.dismiss();
}
}, 3000);
}
public void onSignupSuccess() {
_signupButton.setEnabled(true);
setResult(RESULT_OK, null);
finish();
}
public void onSignupFailed() {
Toast.makeText(getBaseContext(), "Login failed", Toast.LENGTH_LONG).show();
_signupButton.setEnabled(true);
}
public boolean validate() {
boolean valid = true;
String name = _nameText.getText().toString();
String email = _emailText.getText().toString();
String password = _passwordText.getText().toString();
if (name.isEmpty() || name.length() < 3) {
_nameText.setError("at least 3 characters");
valid = false;
} else {
_nameText.setError(null);
}
if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
_emailText.setError("enter a valid email address");
valid = false;
} else {
_emailText.setError(null);
}
if (password.isEmpty() || password.length() < 4 || password.length() > 10) {
_passwordText.setError("between 4 and 10 alphanumeric characters");
valid = false;
} else {
_passwordText.setError(null);
}
return valid;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
MyUtilities.hideSoftKey(SignupActivity.this,v);
return true;
}
}
评估所有进程中主模块中的@everywhere something
。在这种情况下,不在something
模块中,因此在第二种情况下而不在第一种情况下的错误。
也许
test
是什么意思。