Suppose I have such packages:
package test
package test.views
package test.others
package views
Now in a scala file, I want to import test._ and views._(not test.views._), so I write:
import test._
import views._
But when I use some classes under views._, it reports type xxx not found, unless I change views package to another name.
What should I do now?
You can switch package import order (theoretically it should work):
import views._
import test._
Or you can be more precise in views import:
import _root_.views._
Here's yet another way (though using _root_ is the surest way to go):
import test.{views => testviews, _}
import views._
Related
I've installed keras-rl package on my computer, using their instructions:
git clone https://github.com/matthiasplappert/keras-rl.git
cd keras-rl
python setup.py install
So my conda environment sees this package, however when I am trying to import it in Spyder as a part of my code, i.e. import keras-rl, I get the following error:
SyntaxError: invalid syntax
with a pointer to the dash of keras-rl.
Question: How could I import the keras-rl (or any other package with the dash in the name) in Spyder?
We can install keras-rl by simply executing
pip install keras-rl
There are various functionalities from keras-rl that we can make use for running RL based algorithms in a specified environment
few examples below
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory
This is how we can use the package.
If you look at the examples present in the github repository, you will see that the various functionalities are imported from rl. Like this:
(root) ~/condaexpts/keras-rl/examples $ grep -h import * | grep rl
from rl.agents import ContinuousDQNAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.core import Processor
from rl.agents.cem import CEMAgent
from rl.memory import EpisodeParameterMemory
from rl.agents import DDPGAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.agents.dqn import DQNAgent
from rl.policy import LinearAnnealedPolicy, BoltzmannQPolicy, EpsGreedyQPolicy
from rl.memory import SequentialMemory
from rl.core import Processor
from rl.callbacks import FileLogger, ModelIntervalCheckpoint
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory
I had the same problem. After lots of examination I found the correct way.
You can import RL by writing this:
"import rl"
and then write your code like:
rl.core.Agent()
I have a jsp project and I am using eclipse. I want to import a couple of external java source code into Java Resources src. Is there a way to do it rather than create a couple of new classes and then copy and paste the code into it? Thank you.
If they're already in the expected package layout for source files, you can just File|Import from the Filesystem.
Actually nobody is getting what if one havn't define package ???
then define package in ur java code as :-
package MyPackage;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
public class NavBackend {
static boolean isNumeric(String str)
{
..............
..............
then in your jsp file you can write like :
<%#page import="MyPackage.NavBackend"%>
I read the source code of KMeans.scala in spark and it confused me with the following code:
import org.apache.spark.Logging
import org.apache.spark.annotation.Experimental
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.mllib.linalg.BLAS.{axpy, scal}
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.rdd.RDD
import org.apache.spark.storage.StorageLevel
import org.apache.spark.util.Utils
import org.apache.spark.util.random.XORShiftRandom
I found the file RDD is in the path "spark-1.4.0\core\src\main\scala\org\apache\spark\rdd" which corresponds to import org.apache.spark.rdd.RDD. But the file MLUtils is in the path "spark-1.4.0\mllib\src\main\scala\org\apache\spark\mllib\util" which corresponds to import org.apache.spark.mllib.util.MLUtils.
Why their import paths start with "org.apache.spark"? It seems they are in the same folder "spark".
Why do their import paths start with "org.apache.spark"?
Path to the source file doesn't determine the package it belongs to, package declarations in it do. Nonetheless, it's standard (and useful in some ways) to put source files in the directory corresponding to the package, under src/main/scala or <subproject(core and mllib in these two cases)>/src/main/scala. Relative to it you can see the directories are org/apache/spark/rdd and org/apache/spark/mllib/util, just as in imports.
I found a carousel source code from internet.
Instead of importing project, I copied it to my project and pasted in the library files.
However, I still have an error on the line:
import com.arduandro.CarouselView.R;
How can I fix it?
Problem occurs on the second line of the following code:
import com.nineoldandroids.view.ViewHelper;
import com.arduandro.CarouselView.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
Are you using Eclipse? If yes, you have to import the .jar and add it to the build path
I have a Scala file and I am using Play Framework 2.0.4 to compile it. Here is a part of it
import play.api.templates.Html;
import play.api.templates.Txt;
import securesocial.controllers.Registration.RegistrationInfo;
import securesocial.controllers.TemplatesPlugin.
import securesocial.core.{SecuredRequest, SocialUser};
import play.api.data.Form;
import securesocial.core.Identity;
import securesocial.core.SecureSocial._;
import securesocial.controllers.PasswordChange.ChangeInfo;
At compile time I get this error
identifier expected but 'import' found.
What is the issue here?
Could it be import securesocial.controllers.TemplatesPlugin.: the trailing dot?
Either remove the dot or make it import securesocial.controllers.TemplatesPlugin._