Consider the following piece of code:
from PyQt5.QtCore import QJsonDocument
json = {
"catalog": [
{
"version": None,
},
]
}
QJsonDocument(json)
Under Python 3.7 and PyQt 5.14.2, it results in the following error at the last line:
TypeError: a value has type 'list' but 'QJsonValue' is expected
QJsonDocument clearly support lists: QJsonDocument({'a': []}) works fine.
So, what's going on?
As it turns out, the None value is the reason. Although the docs clearly show that QJsonDocument supports null values, None is not supported in PyQt5: QJsonDocument({'a': None}) results in
TypeError: a value has type 'NoneType' but 'QJsonValue' is expected.
The developers explained that that was an omission. They have resolved the issue.
Related
I'm trying to load the ruBERT model into Deeppavlov as follows:
#is a dict
config_path = {
"chainer": {
"in": [
"x"
],
"in_y": [
"y"
],
"out": [
"y_pred_labels",
"y_pred_probas"
],
"pipe": [
...
}
}
model = build_model(config_path, download=False)
At the same time, I have all the files of the original ruBERT model locally. However, an error throws when building the model:
OSError: Error no file named pytorch_model.bin found in directory ruBERT_hFace2 but there is a file for TensorFlow weights. Use `from_tf=True` to load this model from those weights.
At the same time, there is nowhere a clear explanation of how to pass this parameter through the build_model function.
How to pass this parameter across build_model correctly?
UPDATE 1
At the moment, the version of Deep Pavlov 1.0.2 is installed.
The checkpoint of the model consists of following files:
Currently there is no way to pass any parameter via build_model. In case of additional parameter you should align the configuration file accordingly. Alternatively you can change it via Python code.
from deeppavlov import build_model, configs, evaluate_model
from deeppavlov.core.commands.utils import parse_config
config = parse_config(f"config.json")
...
model = build_model(config, download=True, install=True)
But first please make sure that you are using the latest version of DeepPavlov. In addition please take a look at out recent article on Medium. If you need a further assistance please provide more details.
I have created my own Julia package and I am new to such practices.
I previously had this code:
using Parameters
#with_kw mutable struct MWE #deftype String
mwe1 = "default" ; #assert mwe1 in ["default", "1", "2"]
mwe2 = "test"
end
Which worked well. Now that I put it into my package, replacing using with import, I have the following error:
julia> import MyPackageMWE
[ Info: Precompiling RobustRSP [33e6bdf6-6d3e-458b-9f4e-8cd6eb784281]
[ Info: Loading JuMP
[ Info: Loading Gurobi
[ Info: Loading Combinatorics, DelimitedFiles, Dates and Random
[ Info: Loading Distributions, Graphs and Plots
[ Info: Loading Parameters and Formatting
[ Info: Loading Compose, Cairo and Fontconfig
[ Info: Loading .jl files 0%
ERROR: LoadError: UndefVarError: #with_kw not defined
Any ideas what went wrong?
Maybe it is related to #macros?
I don't know the package Parameters but it may be that if #with_kw is exported in Parameters then if you replace
using Parameters
with
import Parameters
then you should change
#with_kw with Parameters.#with_kw
I'm new to modding and I have been trying to add blocks to Minecraft 1.17.1 that I feel are missing. I've had problems before that I solved after a while but this one has had me stumped for a couple days now.
As you can see, my item block models are working just fine along with any cube_all block models. Cube_column models however, are not being registered.
Game Image
Here is my blockstates file along with their models. Maybe you can see the obvious mistake that I can't appear to find.
Blockstates
{
"variants": {
"axis=x": {
"model": "expansion:block/stone_pillar_horizontal",
"x": 90,
"y": 90
},
"axis=y": {
"model": "expansion:block/stone_pillar"
},
"axis=z": {
"model": "expansion:block/stone_pillar_horizontal",
"x": 90
}
}
}
Model
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "expansion:blocks/stone_pillar_top",
"side": "expansion:blocks/stone_pillar"
}
}
Horizontal Model
{
"parent": "minecraft:block/cube_column_horizontal",
"textures": {
"end": "expansion:blocks/stone_pillar_top",
"side": "expansion:blocks/stone_pillar"
}
}
Here is also the terminal message I receive when launching the mod. As you can see, the program for some reason takes issue with 'axis' and claims that my models are missing.
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=z': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=x': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=y': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' missing model for variant: 'expansion:stone_pillar#'
I have double and triple checked that all of my files are where they should be, that there are no simple spelling mistakes and that nothing was left untied. IntelliJ also says that all my work has no flaws that it can tell. Please help me because I can't find it anywhere else :(
I would like to make a graphical visualization of a nested dictionary as a simple tree structure. I have tried several different solutions, but they are too old (python 2.7) or I get weird error messages, even after reinstalling the packages needed.
Here is an example of the nested dictionary. I can change the end nodes value to be whatever value is most useful and the dictionary should be able to scale and be used on a way bigger file structure.
{
"Folder1": {},
"Folder2": {
"Folder21": {},
"Folder22": {}
},
"Document1": {},
"Document2": {},
"Folder3": {
"Document31": {},
"Folder32": {
"Document 321": {},
"Document 322": {}
},
"Folder33": {
"Document331": {}
},
"Folder34": {
"Document341": {}
}
}
}
I have tried solutions using Mapping, NetworkX, GraphViz, pandas, matplotlib 3.1.3, Json, d3py 0.2.3, pyplot, numpy 1.18.1 and Pydot (pydot2 1.0.33, pydotplus 2.0.2).
Using pip3 18.1 to install the packages in Ubuntu 19
Then goal is creating something like this post has, but it is 7 years old, and I can't get it to work after translating from Python2 to Python3.
Python library for creating tree graphs out of nested Python objects (dicts)
Using Selenium Builder, I've created the following json file:
{
"type": "script",
"seleniumVersion": "2",
"formatVersion": 2,
"steps": [
{
"type": "get",
"url": "http://stackoverflow.com/"
},
{
"type": "saveScreenshot",
"file": foo.png"
}
],
"data": {
"configs": {},
"source": "none"
},
"inputs": [],
"timeoutSeconds": 60
}
I tried running it on Windows 7 and two different Ubuntu machines. Instead of the filepath "foo.png" I had also inserted "E:\foo.png" / "/home/swege/foo.png". However, I always get the "exception":
Could not take screenshot of current page - [object Object]
At least I would like to be able to read the "error object", but every system just puts out that the error is a JavaScript object. Any idea how to fix the issue or read the full error message?
Try following :
http://www.ontestautomation.com/how-to-create-screenshots-in-your-selenium-webdriver-tests/
Above can help you to get exact code that how you can take screenshots using selenium.
So I pulled down and looked at the source for Selenium Builder 2 and found two files that I think show the origin of the error, command_processor.js and driver_component.js.
I can't make out why the error is occurring - maybe someone here can build on this?
Try using a full file path, not just foo.png. On Mac, these worked for me: ~/foo.png and ~/Downloads/screenshots/foo.png.
It's also important that the folder exists and is writable by the account running the web browser.