我试图通过使用class SomeDataSerializer(serializers.ModelSerializer):
some_field = serializers.CharField(max_length=100)
def get_fields(self, *args, **kwargs):
fields = super(SomeDataSerializer, self).get_fields(*args, **kwargs)
request = self.context.get('request', None)
if request and getattr(request, 'method', None) == "POST":
fields['some_field'].required = False
return fields
来避免显示其pdf来显示伽玛分布,如下所示:
sns.distplot()
出于某种原因,seaborn用左尾巴显示了以下情节,但是我检查了import seaborn as sns
import numpy as np
from scipy.stats import gamma
# creating a population
shape, scale, size = 2, 1, 200
pop = np.random.gamma(shape, scale, size)
# plotting
sns.distplot(pop, hist=False, kde=False, fit=gamma,
color='r', fit_kws={'color': 'r', 'linewidth': 2.5})
并没有负面的看法。我必须使用pop.min()
来避免它。为什么会发生这种情况,有什么办法可以避免呢?