## Phenomenon related to emergent properties?

I’m looking for a certain word that I am not able to properly define apart from emergent property, and perhaps there is a better alternative.

I am designing a software library, and have 2 decisions to make. Each decision has several alternatives each with it’s own drawbacks. In each decision I choose the seemingly best alternative. However, when I put the two decisions together in the final system, there is an flaw that emerges from the system.

This is like making locally optimal decisions that lead to a globally non-optimal outcome. Is there a known word for this?

## View listing related nodes by taxonomy term

I have a content type representing a book. Each book as a genre (SciFi, Fantasy, Thriller …) and I would like to expose, on the page of a book some books sharing the same genre.

I created a view with a contextual filter on the taxonomy term, but I retrieved the current book so I added a contextual filter on tue current node id to exclude it.

Now I don’t retrieve anything from my view.

Each contextual filter on his own his working. If I just use the contextual filter on the content id, I retrieve the list of my books without the current book. If I just use the contextual filter on the taxonomy term, I retrieve the list of my book for that genre (including my current book).

How am I supposed to proceed to have both filter working together ?

## Python static type checking and related libraries such as mypy. Do you or your team uses it?

Seeing function annotations and static type syntax introduced into Python3. I was curious to know how many developers using Python has found a need to use static typing style in their project.

Medium article giving a quick overview of static type checking in Python3.6 : https://medium.com/@ageitgey/learn-how-to-use-static-type-checking-in-python-3-6-in-10-minutes-12c86d72677b

Looking forward to hear your from you all!

## Coding practices related to logic within function calls and conditional statements

I recently started working as a programmer and I am currently going through some codes (in C#) written by my colleagues. I have noticed that they tend to include logic within function calls within some conditional statements. For example:

if (MoveSpace(currentPos, distance * time)) { doSomething } 

They would also include logic when determining array positions. For example:

Space currentSpace = array[a*b, x*y] 

Is this a good/bad practice? Would it be better if I create a new variable for these logic results and pass in the variable instead? Thank you.

## An idea related to the conjecture of Bunyakovsky

Obviously a reducible polynomial $$f\in\mathbb Z[X]$$ only can have a few primes $$p\in f(\mathbb Z)$$, if any. Irreducible polynomials with a fixed prime divisor can at most have one prime $$p\in f(\mathbb Z)$$. The Bunyakovsky conjecture suggests that for an irreducible polynomial $$p$$ with positive leading coefficient and without fixed prime divisors, $$f(\mathbb Z)$$ must contain infinitely many primes.

But looking at the question from the perspective of the subring of integer valued polynomials over $$\mathbb Q$$, $$\operatorname {int}(\mathbb Z)$$, the occurrence of composites and primes in $$f(\mathbb Z)$$ should be related to the possibility of factoring $$f$$ in $$\operatorname {int}(\mathbb Z)$$. If $$f$$ have a fixed prime divisor the factoring is trivial, but what contradicts a non trivial factorization in $$\operatorname {int}(\mathbb Z)$$ if f not have a fixed prime divisor?

Due to Pólya $$\operatorname {int}(\mathbb Z)$$ is a free Abelian group where all elements $$f$$ can be uniquely expressed as linear combinations of the (in this ring) irreducible polynomials

$$\displaystyle \left( \begin{matrix} X \ k \ \end{matrix}\right)= \frac{X(X-1)(X-2)\cdots(X-k+1)}{k!}$$
where the coefficients can be calculated $$c_0=f(0)$$ and $$\displaystyle c_k=f(k)-\sum_{i=0}^{k-1}c_i {k\choose i}$$.

My question is, does it exist non trivial linear combinations $$f,g\in\operatorname {int}(\mathbb Z)$$, as above, such that $$f\cdot g$$ is an irreducible polynomial in $$\mathbb Z[X]$$?

## Is this Related to Tannakian Formalism?

I am wondering how I might be able to express the following phenomenon, which is essentially equivalent to Artin’s linear independence of characters, in Tannakian formalism. Any help would be much appreciated.

Let $$C$$ be the category of finite étale $$k$$-algebras for a field $$k$$. Let $$K$$ be the separable closure of $$k$$, and let $$G$$ be the absolute Galois group of $$k$$, which is a profinite group.

From the fundamental theorem of Grothendieck’s Galois theory, there is an essentially surjective, fully faithful functor $$\Pi : C \rightarrow G \text{-set}$$ into the category of finite continuous $$G$$-sets. On objects, this functor can be defined by sending a finite étale $$k$$-algebra $$A$$ to the set $$[A, K]_k$$ of $$k$$-algebra maps from $$A$$ to $$K$$ with $$G$$ action given by sending $$\sigma \in G$$ and $$\iota : A \rightarrow K$$ to $$\sigma \circ \iota$$.

There is a functor $$T_{G \text{-set}} : G \text{-set} \rightarrow K \text{-vect}$$ sending a $$G$$-set $$X$$ to $$\oplus_{x \in X} K$$. There is a functor $$T_{k \text{-sep}} : k \text{-sep} \rightarrow K \text{-vect}$$ sending a finite étale $$k$$-algebra $$A$$ to $$\text{Hom}_k (A, K)$$ ($$k$$-vector space maps).

$$T_{k \text{-sep}}$$ and $$T_{G \text{-sep}}$$ factor through the forgetful functor $$K[G] \text{-mod} \rightarrow K \text{-mod}$$, just like in the reconstruction theorem of Tannakian formalism (but keep in mind that this doesn’t meet the hypotheses of this theorem). We may view them as having target $$K[G]$$-mod then.

This seems similar to some sort of Tannakian formalism setup, but maybe it’s just coincidence. Anyways, this formality can be used to express Artin’s linear independence of characters, albeit it is not obvious at first sight that they are essentially the same thing.

Theorem: The following diagram of functors commutes up to natural isomorphism:

That is, $$T_{k \text{-sep}} :$$ is naturally isomorphic to the composition $$T_{G \text{-set}} \circ \Pi$$ sending a finite ètale $$k$$-algebra $$A$$ to $$\oplus_{\iota \in [A, K]_k }$$, and this map is $$G$$-equivariant. More precisely, define a natural transformation $$\epsilon : \Pi \rightarrow T_{k \text{-sep}} \rightarrow T_{G \text{-set}}$$, where $$\epsilon_A$$ sends a formal sum $$\sum_{\sigma : A \rightarrow K} c_{\sigma} \sigma$$ in $$\oplus_{x \in X} K$$ to the $$k$$-linear map $$A \rightarrow K$$ in $$\text{Hom}_{k \text{-mod}} (A, K)$$ sending $$a \in A$$ to $$\sum_{\sigma : A \rightarrow K} c_{\sigma} \sigma (a)$$.

Proof: Take a finite étale $$k$$-algebra $$A$$. First we show that $$\epsilon_A$$ is injective. For a contradiction, suppose $$\epsilon_A$$ is not injective $$\sum_{\sigma \in X} a_{\sigma} \sigma$$ in the kernel of $$\epsilon_A$$, such that the amount of nonzero $$a_{\sigma}$$ is the least possible. Take $$\tau \in X$$, and take $$y \in A$$ such that $$\tau(y) \neq \sigma(y)$$ for some $$\sigma \in X$$ with $$a_{\sigma} \neq 0$$. Then $$\sum_{i = 1} a_{\sigma} \sigma(y) \sigma (x) = \sum_{i = 1}^n a_{\sigma} \sigma (yx) = 0$$ for each $$x \in A$$. And $$\sum_{i = 1}^n a_{\sigma} \tau(y) \sigma(x) = 0$$, so $$\sum_{i = 1}^n (a_{\sigma} \tau(y) – a_{\sigma} \sigma(y)) \sigma$$ is contained in the kernel of $$\phi$$. Yet this element is nonzero, as $$\tau$$ and $$y$$ were chosen so that $$\tau(y) – \sigma(y) \neq 0$$ for some $$\tau \in X$$, and $$a_{\sigma} \neq 0$$. So we have a nonzero element of the kernel of $$\epsilon_A$$ with strictly fewer nonzero summands, a contradiction.

Now $$\epsilon_A$$ is injective, and it has target and cotarget with the same $$K$$-dimension, using the fact that $$A$$ is étale. So $$\epsilon_A$$ is an isomorphism.

So, I am asking whether this is related to Tannakian formalism. I don’t see an abelian cotarget category anywhere, however.

## BUYING: Health, seniors, nurses, babyboomers, age related illness, aging…

Always interested in buying websites, blogs, directories, domains that are related to aging. Including:

• Health and illness of aging people
• Care for aged parents and patients
• Services for seniors (travel, real estate, elder law, etc)
• Facilities for aging people (nursing homes, hospice, adult day care)
• Baby boomers

I am using ADO.NET to read a bunch of data from the database into in-memory objects.

This is my domain model:

// Question.cs public class Question {     public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags { get; set; } }  // Tag.cs public class Tag  {     public int ID { get; set; }     public string Name { get; set; } } 

On retrieving the list of Questions, I would like to fetch the related tags for each question. I am able to do this as follows:

// QuestionRepository.cs  public IList<Question> FindAll() {     var questions = new List<Question>();      using (SqlConnection conn = DB.GetSqlConnection())     {         using (SqlCommand cmd = conn.CreateCommand())         {             cmd.CommandText = "select * from questions";              SqlDataReader reader = cmd.ExecuteReader();              while (reader.Read())             {                 Question question = new Question();                 // Populate the question object using reader                 question.Load(reader);                  questions.Add(question);             }             reader.Close();         }      }     return questions; }   // Question.cs public void Load(SqlDataReader reader) {     ID = int.Parse(reader["ID"].ToString());     Title = reader["Title"].ToString();     Description = reader["Description"].ToString();      // Use Tag Repository to find all the tags for a particular question     Tags = tagRepository.GetAllTagsForQuestionById(ID);  }      return questions; }  // TagRepository.cs public List<Tag> GetAllTagsForQuestionById(int id) {     List<Tag> tags = new List<Tag> ();     // Build sql query to retrive the tags     // Build the in-memory list of tags      return tags; } 

My question is, are there any best practices/patterns for fetching related objects from the database?

Most of the SO questions I came across for loading related data provide the solution for entity framework. There is no answer for this duplicate question.

Even though my code works, I would like to know other ways to do the same. The closest explanation I came across that’s targeting my particular problem was Martin Fowler’s Lazy Load pattern, which I believe, will result in following implementation:

public class Question {     private TagRepository tagRepo = new TagRepository();     private IList<Tag> tags;      public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags {         get         {             if (tags == null)             {                 tags = tagRepo.GetAllTagsForQuestionById(ID);             }             return tags;         }     }   } 

Are there any other alternatives?

## Get related items while looping in Django template

I am trying to access a related object (PaymentDetail if it exists) while looping through a _set list of objects (Registrations).

My models look like this:

models

class Registration(models.Model):     person = models.ForeignKey(Person, on_delete=models.PROTECT)     course_detail = models.ForeignKey(         CourseDetail,         on_delete=models.PROTECT     )     comments = models.CharField(max_length=200, blank=True, null=True)      def __str__(self):         return '%s' % (self.course_detail.course.name)      class PaymentDetail(models.Model):         payment = models.ForeignKey(Payment, on_delete=models.PROTECT)         registration = models.ForeignKey(             Registration,             on_delete=models.PROTECT) 

In my views I’m just getting a queryset of desired people and passing it to the template (these display fine).

view

def index(request, **kwargs):     people = Person.get_related_people(request.user.id).order_by('first_name')     return render(request, 'people_app/index.html', {         'people': people,     }) 

As I am looping through them in the template – I am displaying the associated Registrations for these people. While I’m looping through those registrations – I’m trying to see if there is a PaymentDetail associated with that Registration

In my template I’m looping through the registration_list like this:

template

{% for person in people %}     {% for registration in person.registration_set.all %}         {{ registration.id }}          {% if registration.paymentdetail_set|length > 0 %}             PAID         {% else %}             NO PAYMENT         {% endif %}     {% endfor %} {% endfor %} 

As you may imagine – this doesn’t work and always shows as NO PAYMENT even when the PaymentDetail exists.