Qwen/Qwen2.5-1.5B · L17/N1567 · 20261107T103520Z
Experiment 1 of 1 on this neuron, most conclusive first · record
Fires in source code on the delimiter that introduces a type, package or namespace name in a declaration/qualified-name context: each '.' inside a dotted package/module path (import/package lines, reverse-domain names like org.apache.commons., com.android.), ' extends'/' implements' after a class name, '<' opening generic/template arguments (List<, apply<), '::' in a namespace qualifier (facebook::), and ':' before a parameter type (tableView: UITableView); declaration keywords ' class'/' struct' fire moderately (~0.45-0.6 of max). It stays near zero on '.' in ordinary member access or method calls (user.getName()), on '<' as a comparison, ':' in dict literals, and on all punctuation in English prose (no floor: prose prompts stay ~0).
The whole hypothesis
Fires in source code on the delimiter that introduces a type, package or namespace name in a declaration/qualified-name context: each '.' inside a dotted package/module path (import/package lines, reverse-domain names like org.apache.commons., com.android.), ' extends'/' implements' after a class name, '<' opening generic/template arguments (List<, apply<), '::' in a namespace qualifier (facebook::), and ':' before a parameter type (tableView: UITableView); declaration keywords ' class'/' struct' fire moderately (~0.45-0.6 of max). It stays near zero on '.' in ordinary member access or method calls (user.getName()), on '<' as a comparison, ':' in dict literals, and on all punctuation in English prose (no floor: prose prompts stay ~0).
Hard negatives 13/13 rejected · holdouts 2/7 fired (independent observations; 20 probes) · P(useful) 0.64
Sister study: tests the explanation of openai-community--gpt2/L5/N239-positive/20261028T013202Z, unchanged
specificity 1.00 · sensitivity 0.29 · counterfactual reproduction 0.25 · protocol v0.8
. extends implements<::: struct class
Adversarial review
hard_negative: 13/13 passed; positive_holdout: 2/7 passed; counterfactual: 2/8 passed; lookahead_consistency: 1/1 passed. Failed gates: sensitivity, counterfactual_reproduction, beats_confound_baseline.
All 29 probes
| Test | Input | Expected | Observed | |
|---|---|---|---|---|
| ✓ | hard negative | const display = user.getName().trim().toLowerCase(); Tests '.' in ordinary member-access chains, which the hypothesis says stays near zero. |
inactive | 0.094 |
| ✓ | hard negative | if (count < limit && total < budget) {
retry(count + 1);
} Tests '<' as a numeric comparison, which the hypothesis says stays near zero. |
inactive | 0.359 |
| ✓ | hard negative | profile = {"name": "Alice", "city": "Lima", "age": 30} Tests ':' in a dict literal, which the hypothesis says stays near zero. |
inactive | 0.330 |
| ✓ | hard negative | Dear Mrs. Smith: we arrived at 3 p.m. on Tuesday, and the museum tour <exceeded> every hope. Tests that all punctuation in plain English prose stays near zero. |
inactive | 0.272 |
| ✓ | hard negative | Her kindness extends to every stranger she meets along the mountain road. Tests the word 'extends' in its ordinary prose verb sense, not a class declaration. |
inactive | 0.048 |
| ✓ | hard negative | Our class visited the natural history museum on Tuesday afternoon. Tests the word 'class' in its school-group prose sense, not a code declaration. |
inactive | 0.104 |
| ✓ | hard negative | The server at 192.168.0.1 runs firmware version 2.4.18 build 3021. Tests dots in an IP address and version number, not a package path. |
inactive | 0.104 |
| ✓ | hard negative | factorial :: Integer -> Integer Tests '::' in a Haskell type signature, not a namespace qualifier. |
inactive | 1.056 |
| ✓ | hard negative | let status = age >= 18 ? 'adult' : 'minor'; Tests ':' in a ternary conditional, not before a parameter type. |
inactive | 0.287 |
| ✓ | hard negative | // TODO: see notes on org.apache.commons for later reference before release Tests a dotted reverse-domain name inside a comment, not a declaration context. |
inactive | 0.074 |
| ✓ | hard negative | def add(a, b):
total = a + b
return total Tests code on the same topic with no qualified names, generics, or type delimiters. |
inactive | 1.062 |
| ✓ | hard negative | logger.info(session.getUser().getId().toString()); Tests '.' in a Java logging call chain typical of member access. |
inactive | 0.144 |
| ✓ | hard negative | <div class="banner"><p>Hello visitors</p></div> Tests '<' in markup tags, not generic type arguments. |
inactive | 0.763 |
| ✗ | positive holdout | import org.apache.commons.lang3.StringUtils; Holdout: dotted package path in a fresh Java import line. |
active | 0.047 |
| ✗ | positive holdout | public class GoldenRetriever extends Dog implements Trainable { Holdout: class declaration using both extends and implements in a novel hierarchy. |
active | 2.441 |
| ✓ | positive holdout | private Map<String, List<Integer>> cache = new HashMap<>(); Holdout: '<' opening nested generic type arguments in a new container type. |
active | 7.323 |
| ✗ | positive holdout | auto moment = std::chrono::steady_clock::now(); Holdout: '::' namespace qualifiers in a fresh C++ chrono call. |
active | 0.056 |
| ✓ | positive holdout | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { Holdout: ':' before a parameter type in a Swift delegate signature. |
active | 3.839 |
| ✗ | positive holdout | struct Starship {
vessel_name: String,
warp_capacity: f64
} Holdout: struct declaration keyword in a novel Rust-like definition. |
active | 1.625 |
| ✗ | positive holdout | package com.example.billing; Holdout: dotted qualified path in a reverse-domain package statement. |
active | 0.386 |
| ✗ | counterfactual | import org.apache.commons.io.FileUtils; -> import org_apache_commons_io_FileUtils; | Δ 0.60 | Δ -0.01 |
| ✗ | counterfactual | List<String> names; -> List(String) names; | Δ 0.60 | Δ 0.03 |
| ✗ | counterfactual | class Foo extends Bar -> class Foo and Bar | Δ 0.65 | Δ 0.29 |
| ✗ | counterfactual | using namespace facebook::jni; -> using namespace facebook;jni; | Δ 0.40 | Δ 0.00 |
| ✗ | counterfactual | def f(x: int) -> str: -> def f(x= int) -> str: | Δ 0.20 | Δ 0.09 |
| ✗ | counterfactual | template<> struct apply<int> -> template<> struct apply(int) | Δ 0.25 | Δ 0.00 |
| ✓ | counterfactual | class Foo extends Bar { -> class Foo implements Bar { | Δ 0.00 | Δ 0.08 |
| ✓ | counterfactual | String name = user.getName(); -> String name = user.GetName(); | Δ 0.00 | Δ -0.00 |
| ✓ | lookahead consistency | import org.apache.commons.io.FileUtils;; List<String> names;; class Foo extends Bar; using namespace facebook::jni;; def f(x: int) -> str:; template<> struct apply<int>; class Foo extends Bar {; String name = user.getName(); claimed retrospective; measured retrospective (KL=0.0004987, tokens=[' :', ' Base', '\n', ' Foo', '{\n']) |
Minimal pairs
| # | Base → counterfactual | Expected Δ | Observed Δ | Sufficiency | Necessity |
|---|---|---|---|---|---|
| 1 | import org.apache.commons.io.FileUtils; → import org_apache_commons_io_FileUtils; |
0.60 | -0.01 | — | — |
| 2 | List<String> names; → List(String) names; |
0.60 | 0.03 | — | — |
| 3 | class Foo extends Bar → class Foo and Bar |
0.65 | 0.29 | 1.00 effect 0.00104 matched 3.23e-05 / 0.000338 |
0.97 effect 0.000974 matched 8.7e-05 / 0.00219 |
| 4 | using namespace facebook::jni; → using namespace facebook;jni; |
0.40 | 0.00 | — | — |
| 5 | def f(x: int) -> str: → def f(x= int) -> str: |
0.20 | 0.09 | 0.38 effect 7.86e-06 matched 1.12e-05 / 0.000155 |
0.41 effect 1.72e-05 matched 2.6e-05 / 0.000189 |
| 6 | template<> struct apply<int> → template<> struct apply(int) |
0.25 | 0.00 | — | — |
| 7 | class Foo extends Bar { → class Foo implements Bar { |
0.00 | 0.08 | — | — |
| 8 | String name = user.getName(); → String name = user.GetName(); |
0.00 | -0.00 | — | — |
Read more
Δ is the base prompt's peak positive-pole strength minus the counterfactual's, as a fraction of the max activation.
Each causal score ranks the pole's patch effect among the 32 same-layer neurons that change as much between each pair, so 0.5 is typical. Sufficiency patches clean into corrupted, and necessity corrupted into clean. The score is the median over 2 non-control pairs, on next-token KL. Median effect 0.000525 (sufficiency) and 0.000496 (necessity). In the table, each cell gives the percentile, the pole's signed effect, and the matched neurons' median and largest |effect|, in nats of KL. Self-repair (the hydra effect) was mitigated by freezing downstream MLP outputs.
Top-activating examples
Hover a token for its value.
-
10.15
… string JSONData)↵ {↵ var NewRequestObject = new API_JSON.RootObject↵ {↵ Recipient = recipientName,↵ Packages = new API_JSON.Package↵ {↵ foreach (string …
All 712 tokens
Q:↵↵Assign values to dynamic number of sub-classes before serializing to JSON↵↵I am integrating with a courier that requires me to pass box dimensions for each box in my consignment to their API in JSON format. I am able to set individual properties like RecipientName, but am not sure how to pass the box details for the varying number of boxes for each consignment.↵The JSON needs to look like this (example is for a 2 box consignment):↵{↵ "RecipientName": "Joe Bloggs",↵ "Packages" : [{↵ "boxNumber": "1",↵ "boxHeight": 1.55, ↵ "boxLength": 1.55,↵ "boxWidth": 1.55↵ },↵ {↵ "boxNumber": "2",↵ "boxHeight": 2.55, ↵ "boxLength": 2.55,↵ "boxWidth": 2.55↵ }]↵}↵↵I have built 2 classes, one that describes the structure of the JSON, and another that contains the method to serialize the JSON.↵My JSON structure class looks like this (I have used a List because I have read that arrays are a fixed length, and because the number of boxes with vary I cannot use arrays):↵public class API_JSON↵{↵ public class Rootobject↵ {↵ public string RecipientName { get; set; }↵ public List<Package> Packages { get; set; }↵ }↵↵ public class Package↵ {↵ public string boxNumber { get; set; }↵ public double boxHeight { get; set; }↵ public double boxLength { get; set; }↵ public double boxWidth { get; set; }↵ }↵}↵↵And my API methods class looks like this:↵public class API_Methods↵{↵ public string recipientName;↵ public List<string> boxnumber;↵ public List<double> boxHeight;↵ public List<double> boxLength;↵ public List<double> boxWidth;↵↵ public Boolean SubmitConsignment(out string JSONData)↵ {↵ var NewRequestObject = new API_JSON.RootObject↵ {↵ Recipient = recipientName,↵ Packages = new API_JSON.Package↵ {↵ foreach (string item in ContainerNumber)↵ {↵ boxNumber=???,↵ boxHeight=???,↵ boxLength???=,↵ boxWidth=???↵ }↵ }↵ }↵↵ string JSONData = JsonConvert.SerializeObject(NewRequestObject);↵ return true;↵ }↵}↵↵I am then instantiating the object, setting its public variables, then running the method list this:↵API_Methods myObject = new API_Methods();↵myObject.recipientName;↵myObject.boxnumber.Add(1);↵myObject.boxnumber.Add(2);↵myObject.boxHeight.Add(1.55);↵myObject.boxHeight.Add(2.55);↵myObject.boxLength.Add(1.55);↵myObject.boxLength.Add(2.55);↵myObject.boxWidth.Add(1.55);↵myObject.boxWidth.Add(2.55);↵↵bool test = API_Methods.SubmitConsignment(out JSON);↵↵My problem is with the foreach loop - I know the code is incomplete - but I was hoping to iterate through the lists, but even with an empty foreach loop it appears to be the wrong place to put the loop as I start getting syntax errors about an expected "}"↵↵A:↵↵You're actually overcomplica
Values
Token Positive-pole strength string0.000 JSON0.011 Data0.157 )↵0.000 0.170 {↵0.000 0.000 var0.035 New0.407 Request0.061 Object0.019 =0.000 new7.698 API0.000 _JSON0.000 .Root0.249 Object0.119 ↵0.121 0.199 {↵0.534 0.000 Rec0.000 ipient0.060 =0.000 recipient0.000 Name0.020 ,↵0.014 0.147 Packages0.000 =0.000 new10.153 API0.000 _JSON0.110 .Package0.000 ↵0.128 0.307 {↵0.469 0.000 foreach1.350 (0.000 string0.000 -
9.27
… )↵ {↵ DataSet ds = new DataSet();↵ string connStr = ConfigurationManager.ConnectionStrings["DynamicsConnectionString"].ConnectionString;↵ using (SqlConnection conn = new SqlConnection(connStr))↵ {↵ string sql = …
All 731 tokens
Q:↵↵How to change XML from dataset into HTML UL↵↵I'm working on a C# webforms application and have a datalayer which gathers information about the menu a customer can see, based on their customer number and order type.↵I was using the ASP.NET menu control for this until the qa department asked to change the menu to expand on click instead of hover. At that point, I decided to try and do the menu with a simpler css/html/jquery approach but I've hit a jam.↵I have the following method in my datalayer that gets information for the menu and returns it as XML. What I'm stuck on is how to take the XML that was being gathered, when I was using the menu control and hopefully reformat it into a UL for using in the html/css approach I'd like to do. ↵public static string BuildMenu(string cprcstnm, string docType)↵ {↵ DataSet ds = new DataSet();↵ string connStr = ConfigurationManager.ConnectionStrings["DynamicsConnectionString"].ConnectionString;↵ using (SqlConnection conn = new SqlConnection(connStr))↵ {↵ string sql = "usp_SelectItemMenuByCustomer";↵ SqlDataAdapter da = new SqlDataAdapter(sql, conn);↵ da.SelectCommand.CommandType = CommandType.StoredProcedure;↵ da.SelectCommand.Parameters.Add("@CPRCSTNM", SqlDbType.VarChar).Value = cprcstnm;↵ da.SelectCommand.Parameters.Add("@DOCID", SqlDbType.VarChar).Value = docType;↵ da.Fill(ds);↵ da.Dispose();↵ }↵ ds.DataSetName = "Menus";↵ ds.Tables[0].TableName = "Menu";↵ DataRelation relation = new DataRelation("ParentChild",↵ ds.Tables["Menu"].Columns["MenuID"],↵ ds.Tables["Menu"].Columns["ParentID"],↵ false);↵↵ relation.Nested = true;↵ ds.Relations.Add(relation);↵↵ return ds.GetXml();↵ }↵↵A sample of XMl that is output is as follows: ↵<Menus>↵- <Menu>↵ <MenuID>23</MenuID> ↵ <ITEMNMBR>0</ITEMNMBR> ↵ <Text>ACC</Text> ↵ <Description>ACC</Description> ↵ <ParentID>0</ParentID> ↵- <Menu>↵ <MenuID>34</MenuID> ↵ <ITEMNMBR>1</ITEMNMBR> ↵ <Text>BASE</Text> ↵ <Description>BASE</Description> ↵ <ParentID>23</ParentID> ↵- <Menu>↵ <MenuID>516</MenuID> ↵ <ITEMNMBR>2</ITEMNMBR> ↵ <Text>HYP</Text> ↵ <Description>HYP</Description> ↵ <ParentID>34</ParentID> ↵↵I would need to convert this to something such as :↵<ul class="dropdown">↵ <li><a href="#">ACC</a>↵ <ul class="sub_menu">↵ <li>↵ <a href="#">BASE</a>↵ <ul>↵ <li>↵ <a href="#">HYP</a>↵ <ul>↵ <li><a href="#">Terminal 1</a></li>↵ <li><a href="#">Terminal 1</a></li>↵ </ul> ↵ </li>↵ </ul>↵</li>↵↵A:↵↵You will get some ideas from the following MSDN link that illustrates writing html from a dataset using xslt↵http://msdn.microsoft.com/en-us/librar
Values
Token Positive-pole strength )↵0.000 0.112 {↵0.000 0.000 DataSet0.000 ds0.000 =0.000 new8.185 DataSet0.000 ();↵0.000 0.000 string0.000 conn0.019 Str0.072 =0.000 ConfigurationManager0.000 .ConnectionStrings0.000 ["0.000 D0.053 ynamics0.007 ConnectionString0.005 "].0.046 ConnectionString0.002 ;↵0.000 0.000 using0.000 (0.000 SqlConnection0.000 conn0.000 =0.000 new9.266 SqlConnection0.000 (conn0.120 Str0.000 ))↵0.000 0.358 {↵0.061 0.000 string0.000 sql0.007 =0.000 -
8.99
… public class Velocity↵{↵ private readonly decimal _velocityInKPH;↵↵ public static Velocity VelocityFromMPH(decimal mph)↵ {↵ return new Velocity(toKph(mph));↵ }↵↵ …
All 539 tokens
Q:↵↵Is a low number of members in a class considered a code smell?↵↵I am currently making a simple to-do list program using the MVC pattern, and thus have a model class for the Notebook. However, something feels "off" as it has a very low number of members.↵The Notebook is composed of categories, which are composed of To-do lists, which are composed of Items. ↵What I cannot place is whether this is a case poor analysis (e.g. there are more members and responsibilities I am just missing them..) or perhaps a code smell that the class is not needed (in that case I'm not sure what to do as I could just have a list of categories in that controller, but then I don't have a notebook entity modelled which seems wrong as well).↵Below is the very simple class I have:↵class Notebook↵{↵ private String title;↵ private List<Category> categories;↵↵ public Notebook(String title, List<Category> categories)↵ {↵ }↵↵ public void setCategories(List<Category> categories)↵ {↵ }↵↵ public List<Category> getCategories()↵ {↵ }↵}↵↵I often have this issue where it feels like I am making classes for the sake of it and they have a very number of members/responsibilities, so it would be nice to know whether I am stressing for no reason or not.↵↵A:↵↵Not necessarily, there is the concept in Domain Driven Design of what is called a "Standard Type". Which is really a basic primitive wrapped in an object class. The idea is that the primitive contains no information about what information it contains, it's just a string/int/whatever. So by having say an object that surrounds the primitive and ensures that it is always valid ensures that the object has a meaning far beyond just the primitive it contains e.g. a Name is not just a string, it's a Name.↵Here's an example taken from the comments of Velocity↵public class Velocity↵{↵ private readonly decimal _velocityInKPH;↵↵ public static Velocity VelocityFromMPH(decimal mph)↵ {↵ return new Velocity(toKph(mph));↵ }↵↵ private Velocity(decimal kph)↵ {↵ this._velocityInKPH = kph;↵ }↵↵ public decimal Kph↵ {↵ get{ return this._velocityInKPH; }↵ }↵↵ public decimal Mph↵ {↵ get{ return toMph(this._velocityInKPH); }↵ }↵↵ // equals addition subtraction operators etc.↵↵ private static decimal ToMph(decimal kph){ // conversion code }↵ private static decimal ToKph(decimal mph){ // conversion code }↵}↵↵
Values
Token Positive-pole strength public1.667 class2.575 Velocity0.003 ↵0.000 {↵0.000 0.000 private0.000 readonly0.082 decimal0.000 _0.000 velocity0.078 In0.000 K0.000 PH0.099 ;↵↵0.000 0.000 public2.034 static0.000 Velocity0.000 Velocity0.000 From0.000 MP0.060 H0.152 (decimal0.000 mph0.183 )↵0.000 0.074 {↵0.000 0.000 return0.000 new8.985 Velocity0.000 (to0.015 K0.082 ph0.132 (m0.090 ph0.035 ));↵0.018 0.000 }↵↵0.000 0.000 -
8.39
… : Project) {↵ private val vcsManager by lazy(LazyThreadSafetyMode.NONE) {↵ (ProjectLevelVcsManager.getInstance(project) as ProjectLevelVcsManagerImpl)↵ }↵↵ …
All 627 tokens
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.↵package com.intellij.openapi.vcs.impl↵↵import com.intellij.ProjectTopics↵import com.intellij.openapi.application.ApplicationManager↵import com.intellij.openapi.components.service↵import com.intellij.openapi.extensions.ExtensionNotApplicableException↵import com.intellij.openapi.module.Module↵import com.intellij.openapi.module.ModuleManager↵import com.intellij.openapi.project.ModuleListener↵import com.intellij.openapi.project.Project↵import com.intellij.openapi.project.rootManager↵import com.intellij.openapi.roots.ModuleRootEvent↵import com.intellij.openapi.roots.ModuleRootListener↵import com.intellij.openapi.startup.StartupActivity↵import com.intellij.openapi.vcs.AbstractVcs↵import com.intellij.openapi.vcs.ProjectLevelVcsManager↵import com.intellij.openapi.vcs.VcsDirectoryMapping↵import com.intellij.openapi.vfs.VirtualFile↵↵internal class ModuleVcsDetector(private val project: Project) {↵ private val vcsManager by lazy(LazyThreadSafetyMode.NONE) {↵ (ProjectLevelVcsManager.getInstance(project) as ProjectLevelVcsManagerImpl)↵ }↵↵ internal class MyPostStartUpActivity : StartupActivity.DumbAware {↵ init {↵ if (ApplicationManager.getApplication().isUnitTestMode) {↵ throw ExtensionNotApplicableException.INSTANCE↵ }↵ }↵↵ override fun runActivity(project: Project) {↵ val vcsDetector = project.service<ModuleVcsDetector>()↵↵ val listener = vcsDetector.MyModulesListener()↵ val busConnection = project.messageBus.connect()↵ busConnection.subscribe(ProjectTopics.MODULES, listener)↵ busConnection.subscribe(ProjectTopics.PROJECT_ROOTS, listener)↵↵ if (vcsDetector.vcsManager.needAutodetectMappings()) {↵ vcsDetector.autoDetectVcsMappings(true)↵ }↵ }↵ }↵↵ private inner class MyModulesListener : ModuleRootListener, ModuleListener {↵ private val myMappingsForRemovedModules: MutableList<VcsDirectoryMapping> = mutableListOf()↵↵ override fun beforeRootsChange(event: ModuleRootEvent) {↵ myMappingsForRemovedModules.clear()↵ }↵↵ override fun rootsChanged(event: ModuleRootEvent) {↵ myMappingsForRemovedModules.forEach { mapping -> vcsManager.removeDirectoryMapping(mapping) }↵ // the check calculates to true only before user has done any change to mappings, i.e. in case modules are detected/added automatically↵ // on start etc (look inside)↵ if (vcsManager.needAutodetectMappings()) {↵ autoDetectVcsMappings(false)↵ }↵ }↵↵ override fun moduleAdded(project: Project, module: Module) {↵ myMappingsForRemovedModules.removeAll(getMappings(module))↵ autoDetectModuleVcsMapping(module)↵ }↵↵ override fun beforeModuleRemoved(project: Project, module: Module) {↵ myMappingsForRemovedModules.addAll(getMappings(module))↵ }↵ }↵↵ private fun autoDetectVcsMappings(tryMapPieces: Boolean) {↵ if (vcsM
Values
Token Positive-pole strength :2.171 Project0.053 )0.000 {↵0.000 0.000 private0.000 val0.000 v0.054 cs0.073 Manager0.176 by0.000 lazy0.000 (L0.000 azy0.000 Thread0.215 Safety0.178 Mode0.000 .NONE0.000 )0.000 {↵0.000 0.000 (0.000 Project0.000 Level0.000 V0.001 cs0.087 Manager0.000 .getInstance0.001 (project0.000 )0.000 as8.389 Project0.000 Level0.004 V0.000 cs0.000 Manager0.000 Impl0.000 )↵0.000 0.000 }↵↵0.006 0.000 -
8.34
… WeatherTodayDataHelper.WeatherTodayDBInfo.JSON)), WeatherTodayModel.class);↵ addToCache(model);↵ return model;↵ }↵↵ public static class WeatherTodayRequestData {↵ public WeatherTodayModel …
All 417 tokens
package tk.woppo.sunday.model;↵↵import android.database.Cursor;↵↵import com.google.gson.Gson;↵import com.google.gson.annotations.SerializedName;↵↵import java.util.HashMap;↵↵import tk.woppo.sunday.dao.WeatherDataHelper;↵import tk.woppo.sunday.dao.WeatherTodayDataHelper;↵↵/**↵ * Created by Ho on 2014/7/4.↵ */↵public class WeatherTodayModel extends BaseModel {↵↵ private static final HashMap<String, WeatherTodayModel> CACHE = new HashMap<String, WeatherTodayModel>();↵↵ /** ���市ID */↵ @SerializedName("cityid")↵ public String id;↵↵ /** ���市名称 */↵ @SerializedName("city")↵ public String cityName;↵↵ /** ��度 */↵ public String temp;↵↵ /** ��气 */↵ public String weather;↵↵ /** ���向 */↵ @SerializedName("WD")↵ public String wind;↵↵ /** ���力 */↵ @SerializedName("WS")↵ public String ws;↵↵ /** ���度 */↵ @SerializedName("SD")↵ public String sd;↵↵ /** 发布时间 */↵ public String time;↵↵ private static void addToCache(WeatherTodayModel model) {↵ CACHE.put(model.id, model);↵ }↵↵ private static WeatherTodayModel getFromCache(String id) {↵ return CACHE.get(id);↵ }↵↵ public static WeatherTodayModel fromJson(String json) {↵ return new Gson().fromJson(json, WeatherTodayModel.class);↵ }↵↵ public static WeatherTodayModel fromCursor(Cursor cursor) {↵ String id = cursor.getString(cursor.getColumnIndex(WeatherDataHelper.WeatherDBInfo.ID));↵ WeatherTodayModel model = getFromCache(id);↵ if (model != null) {↵ return model;↵ }↵ model = new Gson().fromJson(cursor.getString(cursor.getColumnIndex(WeatherTodayDataHelper.WeatherTodayDBInfo.JSON)), WeatherTodayModel.class);↵ addToCache(model);↵ return model;↵ }↵↵ public static class WeatherTodayRequestData {↵ public WeatherTodayModel weatherinfo;↵ }↵}↵
Values
Token Positive-pole strength Weather0.000 Today0.000 Data0.005 Helper0.000 .We0.000 ather0.007 Today0.030 DB0.103 Info0.000 .JSON0.005 )),1.929 Weather0.000 Today0.000 Model0.000 .class0.000 );↵0.000 0.122 addTo0.072 Cache0.000 (model0.023 );↵0.000 0.000 return0.000 model0.000 ;↵0.000 0.000 }↵↵0.000 0.000 public0.980 static0.177 class8.344 Weather0.001 Today0.000 Request0.000 Data0.000 {↵0.000 0.000 public0.773 Weather0.000 Today0.000 Model0.000 -
8.26
… };",↵ // serveris.ToString(), port.ToString(), user.ToString(),↵ // password.ToString(), database.ToString());↵ NpgsqlConnection ncon = new NpgsqlConnection(connectionstring);↵ NpgsqlCommand listfill …
All 654 tokens
Q:↵↵Listbox returns System.Data.DataRowView instead of values↵↵I am doing a project for my school, where I have to make a C# Windows Forms application that lets me interact with my PostgreSQL database. I have made a listbox, which is supposed to get the names of the tables from my database, and when I select these names, data from that table is show in the datagridview object in the form. The problem is, however, all my listbox values are System.Data.DataRowView, and datagridview only displays values from the first table in the list.↵The code: ↵ DataTable tabulusaraksts = new DataTable();↵ DataTable tabula = new DataTable();↵ NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();↵ NpgsqlDataAdapter adapter2 = new NpgsqlDataAdapter();↵ string tab;↵ public datubaze()↵ {↵ InitializeComponent();↵ string connectionstring = "Server=localhost;Port=5432;UserId=postgres;Password=students;Database=retrospeles;";↵ //string connectionstring = String.Format("Server={0};Port={1};" +↵ // "User Id={2};Password={3};Database={4};",↵ // serveris.ToString(), port.ToString(), user.ToString(),↵ // password.ToString(), database.ToString());↵ NpgsqlConnection ncon = new NpgsqlConnection(connectionstring);↵ NpgsqlCommand listfill = new NpgsqlCommand("select table_name from INFORMATION_SCHEMA.tables WHERE table_schema = ANY (current_schemas(false));", ncon);↵ adapter.SelectCommand = listfill;↵ adapter.Fill(tabulusaraksts);↵ listBox1.DataSource = tabulusaraksts;↵ listBox1.DisplayMember = "table_name";↵ NpgsqlCommand showtable = new NpgsqlCommand("select * from " + tab +";" , ncon);↵ adapter2.SelectCommand = showtable;↵ }↵public void listBox1_SelectedIndexChanged(object sender, EventArgs e)↵ {↵↵ tab = listBox1.GetItemText(listBox1.SelectedItem);↵ adapter2.Fill(tabula);↵ dataGridView1.DataSource = tabula;↵}↵↵A:↵↵That code should work. I tried it with some test data and ListBox was filled with correct values.↵To be sure, try to also set ValueMember like ↵listBox1.DisplayMember = "table_name";↵↵I think the best approach is to add DataTable rows to your ListBox using loop or Linq list. After filling tabulusaraksts iterate through DataRows and add them as items to ListBox, without setting DataSource Something like this (Linq):↵adapter.SelectCommand = listfill;↵adapter.Fill(tabulusaraksts);↵listBox1.Items.AddRange(tabulusaraksts.AsEnumerable().Select(row => row[0].ToString()).ToArray());↵NpgsqlCommand showtable = new NpgsqlCommand("select * from " + tab +";" , ncon);↵adapter2.SelectCommand = showtable;↵↵or, using foreach loop↵adapter.SelectCommand = listfill;↵adapter.Fill(tabulusaraksts);↵↵listBox1.Items.Clear();↵foreach (DataRow row in tabulusaraksts.Rows)↵{↵ listBox1.Items.add(tabulusaraksts[0].ToString());↵}↵↵NpgsqlCommand showtable = new NpgsqlCommand("select * from " + tab +";" , ncon);↵adapter2.SelectCommand =
Values
Token Positive-pole strength };0.002 ",↵0.000 0.000 //0.076 0.000 server0.013 is0.021 .ToString0.370 (),0.000 port0.000 .ToString0.036 (),0.000 user0.004 .ToString0.024 (),↵0.001 0.000 //0.037 0.000 password0.000 .ToString0.006 (),0.016 database0.000 .ToString0.000 ());↵0.032 0.012 Npgsql0.000 Connection0.000 n0.017 con0.214 =0.000 new8.263 Npgsql0.000 Connection0.000 (connection0.260 string0.115 );↵0.000 0.000 Npgsql0.152 Command0.000 list0.000 fill0.000 -
8.25
… null;↵↵ public LibraryItemDetailsView View↵ {↵ get↵ {↵ if (_view == null)↵ {↵ _view = new LibraryItemDetailsView();↵ }↵ return _ …
All 389 tokens
Q:↵↵Silverlight resource constructor always return to internal↵↵When I modify my resource file (.resx) add text or modify, the constructor of my resource always go to internal and after that, when I run my silverlight I have an error in my binding XAML.↵Is there a way to avoid this scenario? I need to go in the designer of my resource and put the constructor to public to solve the problem↵I use my resource like this in my xaml file↵ <UserControl.Resources>↵ <resources:LibraryItemDetailsView x:Key="LibraryItemDetailsViewResources"></resources:LibraryItemDetailsView>↵ </UserControl.Resources>↵↵<TextBlock FontSize="12" FontWeight="Bold" Text="{Binding Path=FileSelectedText3, Source={StaticResource LibraryItemDetailsViewResources}}"></TextBlock>↵↵A:↵↵Another way to do this without code changes is as below. Worked well for me.↵http://guysmithferrier.com/post/2010/09/PublicResourceCodeGenerator-now-works-with-Visual-Studio-2010.aspx↵↵A:↵↵You can create a public class that exposes the resources through a property:↵public class StringsWrapper↵{↵ private static LibraryItemDetailsView _view = null;↵↵ public LibraryItemDetailsView View↵ {↵ get↵ {↵ if (_view == null)↵ {↵ _view = new LibraryItemDetailsView();↵ }↵ return _view;↵ }↵ }↵}↵↵Then in your XAML you can access your resource:↵<UserControl.Resources>↵ <StringsWrapper x:Key="LibraryItemDetailsViewResources"></StringsWrapper>↵</UserControl.Resources>↵↵<TextBlock FontSize="12" FontWeight="Bold" Text="{Binding Path=View.FileSelectedText3, Source={StaticResource LibraryItemDetailsViewResources}}"></TextBlock>↵↵This way the resx constructor can be internal!↵↵
Values
Token Positive-pole strength null0.000 ;↵↵0.000 0.000 public2.093 Library0.000 Item0.000 Details0.010 View0.000 View0.000 ↵0.000 0.159 {↵0.000 0.000 get0.000 ↵0.101 0.225 {↵0.000 0.000 if0.000 (_0.005 view0.020 ==0.005 null0.000 )↵0.121 0.688 {↵0.091 0.000 _0.076 view0.047 =0.000 new8.250 Library0.059 Item0.000 Details0.000 View0.158 ();↵0.012 0.000 }↵0.046 0.031 return0.000 _0.000 -
8.24
… ção da classe Pessoa↵class Pessoa {↵ public $nome;↵}↵↵// No Controller que envia os parametros↵session_start();↵$joao = new Pessoa();↵$joao->nome = "Jo …
All 798 tokens
Q:↵↵Como passar objetos entre controllers no MVC utilizando POO↵↵Basicamente, eu preciso que ser o login for bem sucedido salvar o nome de usuário em uma variável e utilizar-lá em outro controller.↵Model.php:↵ public function login($email, $password) {↵ session_start();↵↵ $sql = "SELECT * FROM users WHERE email = :email AND password= :password;";↵ $query = $this->db->prepare($sql);↵↵ $parameters = array(':email' => $email, ':password' => $password);↵ $query->execute($parameters);↵ $rows = $query->fetch(PDO::FETCH_NUM);↵↵ if($rows > 0) {↵ header ("Location: " . URL . "home");↵ } else {↵ exit ('Email or password incorrect');↵ }↵}↵↵Controller.php ↵ public function login() {↵ if (isset($_POST['login_submit']) AND isset($_POST['email']) AND isset($_POST['password'])) {↵ $this->model->login($_POST['email'], $_POST['password']);↵ }↵}↵↵A:↵↵Não foi explicito mas parece que você quer que seja mandado por session. Sendo assim você pode simplesmente setar na sessão e pegar de volta no outro controle.↵<?php↵// declaração da classe Pessoa↵class Pessoa {↵ public $nome;↵}↵↵// No Controller que envia os parametros↵session_start();↵$joao = new Pessoa();↵$joao->nome = "João";↵$_SESSION['pessoa'] = $joao;↵↵// No Controller que recebe os dados↵session_start();↵$joao = $_SESSION['pessoa'];↵print_r($joao);↵↵Ou se quiser padronizar isso e jogar no paradigma de orientação a objetos↵<?php↵↵// controller que envia ↵$joao = new Pessoa();↵$joao->nome = "João";↵SessionUtils::setPropriedade('pessoa', $joao);↵↵// controller que recebe ↵$joao = SessionUtils::getPropriedadeLimpar('pessoa');↵print_r($joao);↵↵// declaração da classe Pessoa↵class Pessoa {↵ public $nome;↵}↵↵// classe util para a sessão↵class SessionUtils {↵↵ private static $BASE_PROPRIEDADES = "props";↵↵ /**↵ * Pega uma propriedade da sessão ↵ * @return a propriedade ou null se não existir↵ */↵ public static function getPropriedade($nome){↵ self::configurarSessao();↵ $sessao = self::getSessao();↵ return @$sessao[$nome];↵ }↵↵ /**↵ * Pega uma propriedade da sessão e depois a exclui da mesma↵ * @return a propriedade ou null se não existir↵ */↵ public static function getPropriedadeLimpar($nome){↵ self::configurarSessao();↵ $sessao = self::getSessao();↵ $valor = @$sessao[$nome];↵ self::setPropriedade($nome, null);↵ return $valor;↵ }↵↵ /**↵ * Seta uma propriedade na sessão↵ */↵ public static function setPropriedade($nome, $valor){↵ self::configurarSessao();↵ $_SESSION[self::$BASE_PROPRIEDADES][$nome] = $valor;↵ }↵↵ /**↵ * Configura a sessão para guardar os itens↵ */↵ private static function configurarSessao(){↵ if(!isset($_SESSION)){↵ session_start();↵ }↵ if(!self::getSessao() || !is_array(self::getSessao())){↵ self::setSessao(array());↵ }↵ }↵↵ private static f
Values
Token Positive-pole strength ção0.000 da0.000 classe0.681 Pessoa0.045 ↵0.000 class4.718 Pessoa0.000 {↵0.000 0.000 public0.014 $0.000 nome0.000 ;↵0.027 }↵↵0.000 //0.001 No0.003 Controller0.000 que0.076 env0.036 ia0.099 os0.000 parametros0.000 ↵0.000 session0.018 _start0.094 ();↵0.000 $0.000 jo0.000 ao0.000 =0.000 new8.238 Pessoa0.000 ();↵0.000 $0.058 jo0.000 ao0.000 ->0.223 nome0.000 =0.058 "0.290 Jo0.016 -
7.67
… boolean hasXCRCSupport() throws IOException {↵ client.sendCommand("feat");↵ String response = client.getReplyString();↵ Scanner scanner = new Scanner(response);↵ while(scanner.hasNextLine()) {↵ …
All 591 tokens
Q:↵↵How to check if file exist when downloading from FTP↵↵I'm downloading from FTP server and I don't know exactly how to check if file already exist. What I want to do is that I retrieve filname from FTP server and then compare it with all files in folder. If file already exists then it compares next FTP filename with all files in folder and so on. ↵I already did comparison and it's working if all files from folder have same name as files on FTP server but if I add some older file then it downloads all files once again and I don't want that. ↵Here is my scratch code:↵String[] names = client.listNames();↵ File folder = new File("c:\\test\\RTR_ZIP\\");↵ String[] filename = folder.list();↵↵ for (;i<names.length;i++) {↵ name = names[i];↵↵ exists=false;↵↵ if (name.contains(".zip")) {↵↵ if (filename.length == 0) {↵ new_file = new FileOutputStream("C:\\test\\RTR_ZIP\\" + name);↵ client.retrieveFile(name, new_file);↵ j++;↵ exists=true;↵ } else {↵ for (;k<filename.length;k++) {↵ name = names[i];↵ i++;↵ name1=filename[k];↵ // CHECK IF FILE EXISTS↵ if (!name.equals(name1)) {↵ new_file = new FileOutputStream("C:\\test\\RTR_ZIP\\" + name);↵ client.retrieveFile(name, new_file);↵ j++;↵ exists=true;↵ } ↵ }↵ }//else↵ }//if contains .zip↵ }//for↵↵Thanks in advance. ↵↵A:↵↵If your ftp server supports XCRC command it could be possible to compare checksum (CRC32) of local and remote file.↵You could iterate all files in the folder and compare its crc with local one.↵import java.io.File;↵import java.io.IOException;↵import java.net.SocketException;↵import java.util.Scanner;↵↵import org.apache.commons.io.FileUtils;↵import org.apache.commons.net.ftp.FTPClient;↵↵public class DownloadFile {↵↵ private FTPClient client = new FTPClient();↵↵ public void connect() throws SocketException, IOException {↵ client.connect("127.0.0.1");↵ client.login("user", "password");↵ }↵↵ public boolean hasXCRCSupport() throws IOException {↵ client.sendCommand("feat");↵ String response = client.getReplyString();↵ Scanner scanner = new Scanner(response);↵ while(scanner.hasNextLine()) {↵ String line = scanner.nextLine();↵ if(line.contains("XCRC")) {↵ return true;↵ }↵ }↵ return false;↵ }↵↵ public boolean isSameFile() throws IOException {↵ if(hasXCRCSupport()) {↵ File file = new File("D:/test.txt");↵ String localCRC = Integer.toHexString((int) FileUtils.checksumCRC32(file))
Values
Token Positive-pole strength boolean0.000 has0.000 X0.057 CR0.000 CS0.000 upport0.000 ()0.000 throws2.278 IOException0.000 {↵0.000 0.000 client0.000 .send0.026 Command0.004 ("0.303 feat0.193 ");↵0.012 0.000 String0.000 response0.123 =0.000 client0.000 .get0.474 Reply0.006 String0.000 ();↵0.000 0.000 Scanner0.000 scanner0.003 =0.000 new7.673 Scanner0.000 (response0.017 );↵0.002 0.044 while0.000 (scanner0.000 .hasNext0.342 Line0.000 ())0.112 {↵0.139 -
7.62
… getSerializable(EXTRA_DATA);↵↵ AlertDialog.Builder dialogBuilder;↵ boolean darkTheme = AppSettings.get().isDarkThemeEnabled();↵ dialogBuilder = new AlertDialog.Builder(getActivity(), darkTheme ?↵ R.style …
All 570 tokens
/*#######################################################↵ * Copyright (c) 2014 Jeff Martin↵ * Copyright (c) 2015 Pedro Lafuente↵ * Copyright (c) 2017-2019 Gregor Santner↵ *↵ * Licensed under the MIT license.↵ * You can get a copy of the license text here:↵ * https://opensource.org/licenses/MIT↵###########################################################*/↵package other.writeily.ui;↵↵import android.app.Dialog;↵import android.os.Bundle;↵import android.support.annotation.NonNull;↵import android.support.v4.app.DialogFragment;↵import android.support.v7.app.AlertDialog;↵import android.text.TextUtils;↵↵import net.gsantner.markor.R;↵import net.gsantner.markor.util.AppSettings;↵↵import java.io.Serializable;↵↵public class WrConfirmDialog extends DialogFragment {↵ public static final String FRAGMENT_TAG = "WrConfirmDialog";↵↵ private static final String EXTRA_TITLE = "EXTRA_TITLE";↵ private static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";↵ public static final String EXTRA_DATA = "EXTRA_DATA";↵↵ private Serializable _data;↵ private ConfirmDialogCallback[] _callbacks;↵ private String _summary;↵↵ public static WrConfirmDialog newInstance(String title, String message,↵ Serializable data, ConfirmDialogCallback... callbacks) {↵ WrConfirmDialog confirmDialog = new WrConfirmDialog();↵ Bundle args = new Bundle();↵ args.putSerializable(EXTRA_DATA, data);↵ args.putString(EXTRA_TITLE, title);↵ args.putString(EXTRA_MESSAGE, message);↵ confirmDialog.setArguments(args);↵ confirmDialog.setCallbacks(callbacks);↵ return confirmDialog;↵ }↵↵ public void setCallbacks(ConfirmDialogCallback[] callbacks) {↵ _callbacks = callbacks;↵ }↵↵ @Override↵ @NonNull↵ public Dialog onCreateDialog(Bundle savedInstanceState) {↵ String title = getArguments().getString(EXTRA_TITLE);↵ String message = getArguments().getString(EXTRA_MESSAGE);↵ _data = getArguments().getSerializable(EXTRA_DATA);↵↵ AlertDialog.Builder dialogBuilder;↵ boolean darkTheme = AppSettings.get().isDarkThemeEnabled();↵ dialogBuilder = new AlertDialog.Builder(getActivity(), darkTheme ?↵ R.style.Theme_AppCompat_Dialog : R.style.Theme_AppCompat_Light_Dialog);↵↵ dialogBuilder.setTitle(title);↵ if (!TextUtils.isEmpty(message)) {↵ dialogBuilder.setMessage(message);↵ }↵↵ dialogBuilder.setPositiveButton(getString(android.R.string.ok), (dialog, which) -> {↵ if (_callbacks != null) {↵ for (ConfirmDialogCallback cdc : _callbacks) {↵ if (cdc != null) {↵ cdc.onConfirmDialogAnswer(true, _data);↵ }↵ }↵ }↵ });↵↵ dialogBuilder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> {↵ dialog.dismiss();↵ for (ConfirmDialogCallback cdc : _cal
Values
Token Positive-pole strength get0.399 Serializable0.000 (EX0.113 TRA0.084 _DATA0.015 );↵↵0.057 0.026 AlertDialog0.000 .Builder0.000 dialog0.006 Builder0.142 ;↵0.000 0.000 boolean0.000 dark0.149 Theme0.123 =0.006 App0.027 Settings0.032 .get0.074 ().0.009 is0.385 Dark0.090 Theme0.016 Enabled0.048 ();↵0.099 0.000 dialog0.029 Builder0.012 =0.000 new7.617 AlertDialog0.000 .Builder0.000 (getActivity0.045 (),0.000 dark0.000 Theme0.000 ?↵0.215 0.044 R0.000 .style0.000 -
7.29
… mauvaiseReponse>↵</questionReponse>↵↵here is my parser:↵try {↵ // instanciation du parser↵ InputStream in = new FileInputStream(nomFichier);↵ XMLInputFactory …
All 751 tokens
Q:↵↵StAX and arraylist java↵↵I'm trying to read an xml document with StAX but I have a little problem and i don't know how to fix it, I've tried to look for over internet (maybe i'm using the wrong key word for my problem :/)↵so I've this XML:↵<questionReponses↵xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'↵xmlns='http://polytis.fr/studentest'↵xsi:schemaLocation='http://polytis.fr/studentest qanda.xsd'>↵<questionReponse>↵ <categorie>Biologie</categorie>↵ <question>Question 1</question>↵ <reponse>reponse correcte 1</reponse>↵ <mauvaiseReponse>reponse fausse 1.1</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 1.2</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 1.3</mauvaiseReponse>↵</questionReponse>↵<questionReponse>↵ <categorie>Chimie</categorie>↵ <question>Question 2</question>↵ <reponse>reponse correcte 2</reponse>↵ <mauvaiseReponse>reponse fausse 2.1</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 2.2</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 2.3</mauvaiseReponse>↵</questionReponse>↵<questionReponse>↵ <categorie>CultureG</categorie>↵ <question>Question 3</question>↵ <reponse>reponse correcte 3</reponse>↵ <mauvaiseReponse>reponse fausse 3.1</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 3.2</mauvaiseReponse>↵ <mauvaiseReponse>reponse fausse 3.3</mauvaiseReponse>↵</questionReponse>↵↵here is my parser:↵try {↵ // instanciation du parser↵ InputStream in = new FileInputStream(nomFichier);↵ XMLInputFactory factory = XMLInputFactory.newInstance();↵ XMLStreamReader parser = factory.createXMLStreamReader(in);↵↵ // lecture des evenements↵ for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {↵ // traitement selon l'evenement↵ switch (event) {↵ case XMLStreamConstants.START_ELEMENT:↵ break;↵ case XMLStreamConstants.END_ELEMENT:↵ if (parser.getLocalName().equals("questionReponse")) {↵ question = new Question(categorieCourante,questionCourante,bonneReponseCourante,mauvaisesReponses);↵ quizz.add(question);↵ } ↵ if (parser.getLocalName().equals("categorie")) {↵ categorieCourante = donneesCourantes;↵ }↵ if (parser.getLocalName().equals("question")) {↵ questionCourante = donneesCourantes;↵ }↵ if (parser.getLocalName().equals("reponse")) {↵ bonneReponseCourante = donneesCourantes;↵ }↵ if (parser.getLocalName().equals("mauvaiseReponse")) {↵ mauvaisesReponses.add(donneesCourantes);↵ }↵ break;↵ case XMLStreamConstants.CHARACTERS:↵ donneesCour
Values
Token Positive-pole strength ma0.368 uv0.056 aise0.047 Re0.036 ponse0.000 >↵0.047 </1.182 question0.117 Re0.000 ponse0.000 >↵↵0.000 here0.000 is0.000 my0.068 parser0.000 :↵0.000 try0.000 {↵0.000 0.000 //0.000 inst0.005 anc0.000 iation0.000 du0.000 parser0.010 ↵0.000 0.000 InputStream0.000 in0.000 =0.000 new7.294 FileInputStream0.000 (n0.000 om0.000 F0.035 ichier0.000 );↵0.000 0.000 XML0.000 Input0.000 Factory0.000 -
7.03
… to "fix things up" before persisting or updating.↵class Order↵{↵ public function __construct()↵ {↵ $this->status = new Status('Default');↵ }↵}↵↵The problem of …
All 621 tokens
Q:↵↵Doctrine2 entity default value for ManyToOne relation property↵↵I've got a Doctrine2 Entity called "Order", which has several status properties. The allowed status' are stored in a different Entity, so there is a ManyToOne relation defined for those entities.↵/**↵ * @ORM\Entity()↵ */↵class Order extends AbstractEntity {↵ // ...↵ /**↵ * @ORM\ManyToOne(targetEntity="Status")↵ * @ORM\JoinColumn(onDelete="NO ACTION", nullable=false)↵ */↵ protected $status;↵↵ /** @ORM\Column(nullable=true) */↵ protected $stringProperty = "default value";↵↵}↵↵I need to set this status property to a default value when creating a new instance of the order object.↵For a "non-relation" property I can simply set it like the $stringProperty above. But how to do it for relations?↵↵I cannot set the value to the id of the related record, as Doctrine2 will complain.↵It's fine if the configured default is a "Reference" to the status entity. The available status' are fixed and won't change (often).↵↵How do I configure the entity to have a proper default relation configured.↵Preferably not in a listener when persisting, as the status may be requested before that.↵↵A:↵↵There are several approaches but I would suggest using the OrderRepository as a factory for creating new orders.↵class OrderRepository↵{↵ public function create()↵ {↵ $order = new Order();↵ $status = $this->_em->find('Status','default'); // or getReference↵ $order->setStatus($status);↵ return $order;↵ }↵}↵↵// In a controller↵$orderRepository = $this->container->get('order_repository');↵$order = $orderRepository->create();↵↵By going with a repository you can initialize complex entity graphs that will be ready for persisting.↵==========================================================================↵Plan B would be to do this sort of thing within the order object and then use listeners to "fix things up" before persisting or updating.↵class Order↵{↵ public function __construct()↵ {↵ $this->status = new Status('Default');↵ }↵}↵↵The problem of course is that a default status object already exists in the database so when you flush you will get a error. So you need to hang an onFlush(http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#onflush) listener on the entity manager, check to see if the status object is being managed by the entity manager and, if not, replace it with a managed object fetched via the entity manager.↵This approach lets you deal with more "pure" domain models without worrying as much about the persistence layer. On the other hand, dealing with the flush can be tricky. On the gripping hand, once you get it working then it does open up some major possibilities.↵========================================================↵There is also the question of what exactly the status entity does. If all it contains is some sort of status state ('entered',processed') etc. Then you might consider j
Values
Token Positive-pole strength to0.057 "0.000 fix0.000 things0.000 up0.000 "0.008 before0.032 persist0.000 ing0.000 or0.000 updating0.000 .↵0.000 class3.883 Order0.000 ↵0.473 {↵0.138 0.000 public0.475 function0.000 __0.000 construct0.000 ()↵0.000 0.000 {↵0.000 0.039 $0.000 this0.000 ->0.000 status0.000 =0.000 new7.029 Status0.000 ('0.216 Default0.000 ');↵0.000 0.047 }↵0.000 }↵↵0.000 The0.011 problem0.122 of0.026
Read more
Each token is shaded by positive-pole strength, as a fraction of the neuron's max activation. Each window shows up to 30 tokens before the peak and 10 after it.
Explanation scores on held-out text
How well a judge with only the hypothesis predicts the unit on new text. 0.5 is chance.
Read more
The judge reads 32-token windows of corpus text that the proposer never saw. Detection: it picks the windows that activate the unit. Fuzzing: it checks whether the marked tokens are the active ones. Recorded, not gated.
Detection recall by activation strength
False alarms on inactive windows: 0%.
- Judge
- muse-spark-1.3
- Held-out windows
- 18 active of 4,000
- Judged
- 20 detection · 12 fuzzing
- Detection outcomes
- 7 missed · 0 false alarm · 3 hit · 10 correct rejection
- Seed
- 740020214 · NeelNanda/pile-10k@127bfedc (data/*.parquet, first 500 docs)
Detection windows (20), the explanation's mistakes first
- missed 3.61 · sim 0.21 qiraj.h"↵↵enum↵{↵ // kri↵ SPELL_CLEAVE = 26350,↵ SPELL_TOXIC
- missed 3.30 · sim 0.30 )↵#pragma warning(pop)↵#elif defined(__GNUC__)↵#pragma GCC diagnostic pop↵#elif defined(__clang__)↵#pragma clang diagnostic pop↵#endif↵↵#endif↵
- missed 3.12 · sim -0.03 "↵ target.value = ""↵ end if↵ else↵ Dim value as string↵ value = range("$A$1").value↵ if
- missed 2.99 · sim 0.25 (push)↵#pragma warning(disable:4250)↵#elif defined(__GNUC__)↵#pragma GCC diagnostic push↵#pragma GCC diagnostic ignored "-Wparentheses-equality
- missed 2.82 · sim 0.01 697*n - 694*n + 3*i for n.↵-5↵Solve 5*d - 27 =
- missed 2.75 · sim 0.14 },↵ },↵ ChallengePassword: "foobar",↵ }↵↵ derBytes, err := CreateCertificateRequest(r, &template, priv)↵
- missed 2.69 · sim 0.00 ;↵ type = dbm.dataType;↵ seed = seedLink;↵};↵↵exports.up = function (db) {↵ return Promise.all([↵ db.run
- hit 3.65 · sim 0.21 >↵↵#include <jschelpers/JSCHelpers.h>↵#include <jni.h>↵#include <string>↵↵using namespace facebook::jni;↵↵namespace facebook {↵namespace react
- hit 3.47 · sim 0.27 DECL_TYPE_INFO(::demo::MainWindowConstructor)↵#endif↵↵ extern bool LoadDemoTypes();↵ }↵ }↵}↵↵#if defined( _MSC_VER
- hit 2.59 · sim 0.13 |↵ s.name = 'jekyll-last-modified-at'↵ s.version = Jekyll::LastModifiedAt::VERSION↵ s.summary
- correct rejection 0.38 · sim 0.06 lovak footballers↵Category:Association football goalkeepers↵Category:1. FC Tatran Prešov players↵Category:AS Trenčín players↵
- correct rejection 0.37 · sim 0.00 This subproject is one of many research subprojects utilizing the resources provided by a Center grant funded by NIH/NCRR. The subproject and investigator (PI
- correct rejection 0.36 · sim 0.02 ↵↵ZURB Tavern - jacobwg↵http://zurb.com/tavern↵↵======↵pepsi↵By the name, I thought that this was going
- correct rejection 0.34 · sim 0.16 .↵With the finely divided powder or dispersion, a principal problem is retention on the leaves or blades of grass. This can also cause burning. Additionally, ambient conditions
- correct rejection 0.32 · sim 0.10 00 processors just yet, so it’s unclear exactly what chip will power this Yoga Slim 7. We do know that the Ryzen 4000
- correct rejection 0.29 · sim 0.08 in the formation of advanced glycation end-products, and its concentration is also typically higher in diabetes. In this study, we investigated the effects of the treatment of
- correct rejection 0.26 · sim 0.06 Instead Endeavor will get the praise from the masses. It would also explain Stain’s burn scars. So they choose to not be celebrated as heroes and apologize
- correct rejection 0.16 · sim 0.04 coating, assembled, fluxed and brazed without placing additional filler metal at a joint site.↵In one type of roll bonding, the brazing material is bonded
- correct rejection 0.15 · sim 0.14 ---↵abstract: 'The purpose of this article is to study the problem of finding sharp lower bounds for the norm of the product of polynomials in the ultrapro
- correct rejection 0.07 · sim -0.09 of foe trying to stop them from doing so. I kind of had this image of human souls flying in space towards a monolith or a space baby (all
Fuzzing windows (12), dashed tokens were marked for the judge
- marks right · judged wrong != 17:↵ raise # This was not a "directory exist" error..↵ with open(os.path.join(mydir, filename), 'w')
- marks right · judged wrong class implements the `DBSerializable` protocol (serialize and↵/// deserialize instance methods), which is required for all Obj-C SDK API route↵/// objects.↵///↵
- marks right · judged wrong what finally worked - ↵from shutil import copy↵f = open(r'C:\Users\B\Desktop\BE Project\K\filelist.txt', '
- marks right · judged wrong Private Sub Worksheet_SelectionChange(ByVal Target As Range)↵ if target.address = "$A$1" then↵ if target.value = "Enter DOB here
- marks wrong · judged wrong Y-%m-%d_%H-%M-%S'))↵ try:↵ os.makedirs(mydir)↵↵ except OSError, e:↵↵ if e.errno
- marks wrong · judged wrong "↵#elif defined(__clang__)↵#pragma clang diagnostic push↵#pragma clang diagnostic ignored "-Wparentheses-equality"↵#endif↵↵/***********************************************************************↵Reflection↵***********************************************************************/↵↵namespace vl
- marks wrong · judged wrong Exception.additionalFields valueForKey:@"BoxUsage"] != nil) {↵ self.boxUsage = [AmazonSDKUtil convertStringToNumber:[theException.additionalFields valueForKey:@"
- marks wrong · judged wrong C:\BE\2014-03-25_02-49-11↵import os, datetime↵import shutil↵↵
- marks wrong · judged wrong </field> ↵ <field minOccurs="0" maxOccurs="0"> ↵ <name>PD1.5</name> ↵ <description>Student
- marks wrong · judged wrong Radio stations in the Rio Grande Valley↵↵References↵↵Category:Spanish-language radio stations↵Category:Radio stations in Matamoros
- marks wrong · judged wrong people could exercise this area on their own, said co-author Jeff MacInnes, a postdoctoral researcher in Adcock's lab.↵↵advertisement↵↵In the
- marks wrong · judged wrong overlapping, or is there text missing?↵↵These issues mean your website has not been optimised for mobile devices, making it unusable for a large percentage of potential
Activation and mechanism
Activation distribution
Positive-pole strength per token; bar height is log(1 + count).
Mechanism
Claimed retrospective: responds to tokens already in context.
Input attribution
- 0 back
- 28%
- 1 back
- 0%
- 2–4 back
- 9%
- 5–16 back
- 8%
- 17–64 back
- 14%
- 65+ back
- 40%
- #1 (not converged) at
new:new0 0.38=-1 -0.09Assign-451 0.09new-18 0.05{ -11 0.05 - #2 (not converged) at
new:new0 0.46=-1 -0.13conn-2 -0.06new-23 0.04["-13 0.03 - #3 (not converged) at
new:new0 0.30't-274 0.04static-13 0.04{ -26 0.03class-29 0.03 - #4 at
as:as0 0.34(project-2 0.09{ -11 0.05(-9 0.05lazy-19 0.04 - #5 at
class:class0 0.36public-2 0.06-3 0.02{ -317 0.02.class-102 0.02
Shares of the gap to <|endoftext|> at every position but the first · converged on 2 of 5 · mean 90.8 tokens back ·
agreement with replacing one token at a time ρ = 0.39 · reported, not gated
Vocabulary projection
The tokens that this unit's output raises and lowers most.
Jacobian lens
Logit lens
Values
| # | Jacobian lens promotes | suppresses | Logit lens promotes | suppresses | ||||
|---|---|---|---|---|---|---|---|---|
| 1 | Terror |
+4.83 | 新人玩家 |
-3.49 | enef |
+5.29 | [port |
-5.11 |
| 2 | Exam |
+4.75 | hence |
-3.44 | isNaN |
+4.86 | roscope |
-4.23 |
| 3 | Crime |
+4.61 | ."</ |
-3.42 | neur |
+4.58 | Estates |
-4.23 |
| 4 | Puzzle |
+4.38 | delegated |
-3.37 | toán |
+4.57 | 加盖 |
-4.14 |
| 5 | Stroke |
+4.36 | initially |
-3.29 | 比例 |
+4.53 | [__ |
-4.03 |
| 6 | Accident |
+4.36 | ("");
|
-3.26 | 栲 |
+4.39 | [level |
-4.03 |
| 7 | Random |
+4.33 | ="<< |
-3.25 | way |
+4.20 | .boolean |
-4.03 |
| 8 | Symptoms |
+4.27 | .");
|
-3.24 | :? |
+4.07 | 按下 |
-4.02 |
| 9 | Hazard |
+4.26 | /{{$ |
-3.24 | Eval |
+4.06 | (addr |
-3.95 |
| 10 | Documentary |
+4.24 | ="";
|
-3.23 | ?t |
+4.04 | antis |
-3.94 |
Top-10 overlap 0% · cos(w, J·w) 0.48 · kurtosis 3.7 (Jacobian) / 3.2 (logit) · 100 prompts
Read more
The output direction is read through the final norm and the unembedding. The Jacobian lens first carries it to the last layer. Bar length is the token's z-score over the vocabulary, and ␣ marks a space. A kurtosis near 3 means no specific set of tokens.
Patchscope
The model's own description of this unit's output, with no examples.
Read more
The unit's direction replaces the residual stream after the named layer, at the ? of each prompt. It is scaled to each multiple of the norm it replaces, and the model continues greedily. The control injects a random direction, so text that both rows share comes from the prompt. Read after the proposer answered, and shown to neither agent. Reported, not gated.
| Prompt | Layer | ×1 | ×2 | ×4 | |
|---|---|---|---|---|---|
| category | 2 | unit | politician | science | adjective |
| control | furniture | politics | politics | ||
| category | 17 | unit | ? | music | music |
| control | technology | ? | ? | ||
| meaning | 2 | unit | ____. | "to have a certain quality or characteristic". The word " | "to make" or "to create." The word " |
| control | ____. | ____. | : | ||
| meaning | 17 | unit | ____. | ____. | ____. |
| control | ____. | ____. | ____. |
Hover a prompt's name for its text.
Steering
What the model writes with this pole ablated, untouched, and clamped. Text that matches the baseline is faded.
Read more
The prompts are neutral. The clamp is a multiple of the top activation in the scan (10.15), at every token, and decoding is greedy. Drift at ×1 or ×2 shows what the pole makes the model write. Drift only at ×4 is off-distribution. At most 24 new tokens. Taken after the proposer answered, and shown to neither agent. Reported, not gated.
very hot. The temperature is 30 degrees Celsius. If the temperature increases by 5 degrees Celsius tomorrow, what
very hot. The temperature is 30 degrees Celsius. If the temperature increases by 5 degrees Celsius tomorrow, what
very hot. The temperature is 30 degrees Celsius. If the temperature increases by 5 degrees Celsius tomorrow, what
very hot.(改为感叹句) ____ hot the weather today is! It's hot today The boy is very
different from any other day. It is different from any other day in the year. It is different from any other day
a new pair of shoes. I put them on and walked out of the store. I was so happy that I had
a new pair of shoes. I put them on and walked out of the store. I was so happy that I had
some food for the party. I bought some bread, some cheese, and some milk. I paid $3.6
some food for the party. (改为否定句) I didn't go to the shop and buy any food for the
some things for my family. I went to the shop to buy some things for my family, I went to the shop
to do. The best way to do is to practice. The best way to practice is to play. The best way
to do. The best way to do is to practice. The best way to practice is to play. The best way
to do. The best way to do is to play. The best way to play is to have fun. The best
to do. That’s why we offer a variety of hands-on activities and projects. Our students learn by doing, and
to do. That's true for everything, including learning about the Bible. The Bible is a great book, but it
there was a little girl named Lily. She lived in a small village with her parents and grandparents. One day, Lily
there was a little girl named Lily. She lived in a small village with her parents and grandparents. One day, Lily
there was a little girl named Lily. She loved to play with her friends and go on adventures. One day, she
there was a young man named John. He was very curious and adventurous. One day, he decided to explore the world
there was a man named John. He was a man who was very curious about everything, John was John John John John
the number of people who died in the 2010 earthquake was 22,000, with
the number of people who died in the 2010 earthquake was 22,000, with
the number of people who died in the 2010 earthquake was 22,000, with
the number of people who died in the 2010 earthquake was likely to be higher than the 2,
the UK's climate is changing, with more extreme weather events, rising sea levels, and more frequent and intense heatwaves
Wiring
The units that write most directly into this pole (upstream) and read most directly from it (downstream).
Read more
"Directly" means along the residual stream, through no other unit. Linked units have pages in the registry. Reported, not gated.
From the weights. Virtual weights, with each norm's gain folded in. They rank units but have no absolute scale. Each number is how much one unit reads of the other's write. It is signed when one vector reads another (+ means a positive activation raises the read), and a norm otherwise. Heads count through their OV circuit upstream, and through their Q, K and V reads downstream. Channels are on hover.
From activations. Averaged over this pole's peak on 6 of the review's prompts where it fired. Upstream: the first-order change in its strength when a unit's direct write is removed (+ excites). Downstream: the change in a later unit when this pole's write is removed from that unit's input alone (one of Q, K or V for a head).
From the weights
Upstream neurons
| L1/N5246 | gate | -0.15 |
| L2/N1276 | up | -0.142 |
| L10/N2945 | up | -0.138 |
| L12/N1904 | up | +0.137 |
| L16/N6267 | gate | -0.136 |
| L14/N2321 | up | -0.133 |
| L2/N2708 | up | +0.132 |
| L4/N538 | gate | -0.132 |
| L14/N343 | up | +0.132 |
| L1/N1945 | up | +0.129 |
Upstream heads
| L17/H7 | gate | +0.777 |
| L17/H10 | gate | +0.716 |
| L17/H11 | gate | +0.696 |
| L17/H6 | gate | +0.671 |
| L10/H0 | gate | +0.528 |
| L15/H2 | gate | +0.522 |
| L14/H7 | gate | +0.521 |
| L15/H4 | up | +0.517 |
| L5/H5 | gate | +0.497 |
| L15/H8 | gate | +0.489 |
Downstream neurons
| L27/N6837 | up | +0.493 |
| L26/N2908 | up | +0.357 |
| L27/N4490 | up | +0.351 |
| L27/N846 | up | +0.319 |
| L27/N6700 | gate | +0.309 |
| L26/N974 | up | +0.308 |
| L27/N7899 | up | -0.295 |
| L27/N4177 | gate | -0.285 |
| L27/N777 | gate | +0.234 |
| L26/N7035 | up | -0.23 |
Downstream heads
| L27/H6 | v | +1.08 |
| L27/H7 | v | +1.08 |
| L27/H8 | v | +1.08 |
| L27/H9 | v | +1.08 |
| L27/H10 | v | +1.08 |
| L27/H11 | v | +1.08 |
| L27/H0 | v | +0.986 |
| L27/H1 | v | +0.986 |
| L27/H2 | v | +0.986 |
| L27/H3 | v | +0.986 |
From activations
Upstream neurons
| L2/N7119 | +1.09 | |
| L1/N3089 | +0.478 | |
| L8/N2185 | +0.396 | |
| L2/N4968 | +0.38 | |
| L0/N2593 | +0.362 | |
| L1/N6562 | +0.238 | |
| L3/N2308 | +0.201 | |
| L6/N1615 | +0.199 | |
| L3/N7960 | +0.195 | |
| L11/N5617 | +0.168 |
Upstream heads
| L11/H0 | -0.289 | |
| L13/H4 | +0.273 | |
| L10/H8 | +0.213 | |
| L6/H4 | -0.211 | |
| L10/H2 | -0.191 | |
| L1/H3 | -0.186 | |
| L12/H6 | +0.186 | |
| L15/H7 | +0.183 | |
| L11/H3 | +0.182 | |
| L17/H3 | +0.179 |
Downstream neurons
| L20/N4770 | -0.508 | |
| L27/N2646 | +0.496 | |
| L21/N2384 | +0.433 | |
| L27/N7926 | -0.404 | |
| L27/N2457 | -0.392 | |
| L27/N6691 | +0.375 | |
| L18/N555 | -0.36 | |
| L27/N6932 | -0.346 | |
| L20/N1031 | +0.345 | |
| L18/N6615 | +0.31 |
Downstream heads
| L19/H6 | v | +0.949 |
| L18/H10 | v | +0.584 |
| L20/H7 | v | +0.563 |
| L22/H8 | q | +0.493 |
| L25/H3 | v | +0.432 |
| L22/H4 | q | +0.407 |
| L27/H9 | v | +0.346 |
| L27/H11 | q | +0.319 |
| L27/H10 | v | +0.282 |
| L24/H8 | q | +0.261 |
Covariance and confounds
Confounds
- Token identity R²
- 0.35
- Position R²
- 0.01
- Frequency r
- 0.13
- Personal data R² · MI
- 0.00 · 0.000 bits
- Toxicity R² · MI
- 0.00 · 0.000 bits
- Hate speech R² · MI
- 0.00 · 0.000 bits
- Names R² · MI
- 0.00 · 0.002 bits
- Postal addresses R² · MI
- 0.00 · 0.000 bits
- Best trivial baseline
- never active · 0.86
- Hypothesis
- 0.64 ✗
classstruct struct typedef typename newdefined }//#definefunctionpublic throws
Co-activating neuron poles
| Pole | Lift ≥ | Both | ρ | r |
|---|---|---|---|---|
| N7577− | 42.6 | 71 | -0.02 | -0.09 |
| N3605+ | 41.2 | 69 | +0.03 | +0.07 |
| N4261− | 37.8 | 64 | +0.00 | -0.09 |
| N3683− | 37.1 | 63 | +0.05 | -0.08 |
| N1820+ | 33.7 | 58 | +0.05 | +0.22 |
| N2776+ | 32.3 | 56 | -0.01 | +0.08 |
| N6604+ | 32.3 | 56 | -0.01 | +0.10 |
| N4290+ | 31.0 | 54 | +0.03 | +0.08 |
| N7961− | 28.3 | 50 | -0.04 | -0.06 |
| N5854− | 27.7 | 49 | +0.01 | -0.04 |
Read more
Ranked by the 95% lower bound of co-activation lift: how much more often a pole fires when this one does, with chance coincidences discounted. ρ ranks the values, so heavy tails don't sway it.
Joint ablation
- Partners
- N7577, N3605, N4261
- KL pole alone
- 2.04e-04
- KL partners
- 3.17e-04
- KL together
- 5.40e-04
- Redundancy ratio
- 1.09
The partners don't change the pole's effect much.
Run details
- Submitted by
- muse-spark-1.3
- Reviewed by
- muse-spark-1.3 (same model as the proposer: not an independent review)
- Reviewed at
- 2026-11-07 10:35 UTC
- Max activation
- 10.1533
- Selection
- manual
- Corpus
- NeelNanda/pile-10k@127bfedc (data/*.parquet, first 500 docs) · 199,896 tokens · seeded sample of 477/500 docs (≤ 200,000 tokens, seed 0) · licence bigscience-bloom-rail-1.0
- Model revision
- 8faed761d45a · float32
- Ran on
- scan cpu · review cpu
- Run cost
- 119.3 min (slowest: scan, 73.8 min) · 4 LLM calls · 47,439 + 10,875 tokens · $0.01